C语言实现e=1+1/1!+1/2!+1/3!+··· ,求e的近似值,精度要求为10-6

#include"stdio.h"
main()
{
	int i,j,jc;
	float e=1;
	for(i=1;;i++)
	{   jc=1;
		for(j=1;j<=i;j++)
		jc*=j;
		if(jc>=1000000)
		break;
		e+=1.0/jc;
		}
	 printf("%f\n",e);
}

猜你喜欢

转载自blog.csdn.net/kingoflongevity/article/details/105030570