e的计算程序哪里出问题了

来源:百度知道 编辑:UC知道 时间:2024/06/19 09:42:38
用e=1+1/1!+1/2!+1/3!+……计算,当最后一项小于10的负10次方时结束。
#include<stdio.h>
main()
{int i,j;
double t,e;
i=1;t=1;e=1;
while(t>1e-10)
{t=1;
for(j=1;j<=i;j++);
t/=j;
e+=t;
i++;
}
printf("e=%.10lf",e);
getch();
}
运行后半天没反应,为什么呢(计算不是很麻烦呀)

#include<stdio.h>
main()
{int i,j;
double t,e;
i=1;t=1;e=1;
while(t>1e-10)
{t=1;
for(j=1;j<=i;j++) //这里多了个分号-_-!循环体没有执行。。。
t/=j;
e+=t;
i++;
}
printf("e=%.10lf",e);
getch();
}

那个for语句死住了吧