e=1+1/1!+1/2!+1/3!+......
该程序是按照公式e=1+1/1!+1/2!+1/3!+......计算e的近似值,直到最后一项小于1e-4#include <stdio.h>
#include <math.h>
void main()
{
float denominator,sum=0,fraction=1;
int j=0;
do
{
sum+=fraction;
j++;
denominator=1;
for(int i=1;i<=j;i++)
{
denominator*=i;
}
fraction=1/denominator;
}while(fraction<1e-4);
printf("%f",sum);
}
运行结果显示1.000000,请问问题出在哪?