35: obtaining the value of e

35: obtaining the value of e

#include <stdio.h>
int main()
{
	double sum=1;int i,j,n;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		long long temp=1;
		for(j=2;j<=i;j++)temp*=j;
		sum+=(1.0/temp);
	}
	printf("%.10lf\n",sum);
        return 0;
}

 

Guess you like

Origin blog.csdn.net/qq_42861250/article/details/90729601