#include <iostream.h>
void main()
{
long double i, a=1 ,k;
double sum=0, x;
for(i=1;;i++)
{
a=1;
for(k=1;k<=i;k++)
{
a *=k;
}
cout<<a<<endl;
x= 1.0/a;
sum=sum+x;
if(x<=1e-108)
break;
}
cout<<sum;
}注e=1/1!+1/2!+3/3!......
----------------解决方案--------------------------------------------------------
e=1/1!+1/2!+3/3!......
公式记错了吧
----------------解决方案--------------------------------------------------------
这是我写的
//计算 e=1+1/1!+1/2!+1/3!+1/4!+............
#include<stdio.h>
int main()
{
long long cheng =1,i;
double he=1,sum=0;
for (i=1;i<=50;i++)
{
cheng =cheng*i;
he=he +1.0/(float)cheng;
printf("%f\n",he);
}
getchar();
return 0;
}
[此贴子已经被作者于2007-4-6 21:55:56编辑过]
----------------解决方案--------------------------------------------------------
不关K的事,是公式有问题,好像是从1/0!开始
for(k=1;k<=i;k++)
----------------解决方案--------------------------------------------------------
Too Much Tthanks!!!
----------------解决方案--------------------------------------------------------