#include <stdio.h>
#include <math.h>
main()
{
int count = 1,n = 1;
double e = 1.0,term = 1.0;
while(fabs(term) >= 1e-5)
{
term = term / n; //累加项
e = e + term; //累加
count++; //累加的次数
n++;
}
printf("e = %f\ncount = %d\n",e,count);
}
C语言 利用e=1+ (1/1!)+(1/2!) +....+(1/n!)直到最后一项绝对值小于10的-5次方。
最新推荐文章于 2023-11-20 17:34:35 发布