用C语言程序编写求无理数e的值并输出。公式:e=1+1/1!+1/2!+1/3!+......+1/n! 当1/n!<0.000001时e=2.71828

如题所述

#include <stdio.h>
int main()
{
int i=1;
float temp=1;
float sum=0;
while(temp>=1e-6)
{
sum+=temp;
temp/=i;
i++;
}
printf("e=1+1/1!+1/2!+1/3!+.=%f",sum);
return 0;
}
温馨提示:答案为网友推荐,仅供参考
相似回答