十万火急 !浙大OJ 1113 u Calculate e WA 坐等大侠指点Problem DescriptionA simple mathematical formula for e iswhere n is allowed to go to infinity. This can actually yield very accurate approximations of e using relatively small values of n
来源:学生作业帮助网 编辑:作业帮 时间:2024/06/24 22:42:38
![十万火急 !浙大OJ 1113 u Calculate e WA 坐等大侠指点Problem DescriptionA simple mathematical formula for e iswhere n is allowed to go to infinity. This can actually yield very accurate approximations of e using relatively small values of n](/uploads/image/z/14296549-13-9.jpg?t=%E5%8D%81%E4%B8%87%E7%81%AB%E6%80%A5+%21%E6%B5%99%E5%A4%A7OJ+1113+u+Calculate+e+WA+%E5%9D%90%E7%AD%89%E5%A4%A7%E4%BE%A0%E6%8C%87%E7%82%B9Problem+DescriptionA+simple+mathematical+formula+for+e+iswhere+n+is+allowed+to+go+to+infinity.+This+can+actually+yield+very+accurate+approximations+of+e+using+relatively+small+values+of+n)
十万火急 !浙大OJ 1113 u Calculate e WA 坐等大侠指点Problem DescriptionA simple mathematical formula for e iswhere n is allowed to go to infinity. This can actually yield very accurate approximations of e using relatively small values of n
十万火急 !浙大OJ 1113 u Calculate e WA 坐等大侠指点
Problem Description
A simple mathematical formula for e is
where n is allowed to go to infinity. This can actually yield very accurate approximations of e using relatively small values of n.
Output
Output the approximations of e generated by the above formula for the values of n from 0 to 9. The beginning of your output should appear similar to that shown below.
Sample Output
n e
- -----------
0 1
1 2
2 2.5
3 2.666666667
4 2.708333333
这是我的代码
#include
int main()
{
int n,b;
double e=2.00,a=1.00;
printf("n e\n");
printf("- -----------\n");
for(n=0;n=2)
{
a=a/n;
e=e+a;
}
if(n==2)
printf("%.1lf",e);
else
printf("%.9lf\n",e);
}
return 0;
}
十万火急 !浙大OJ 1113 u Calculate e WA 坐等大侠指点Problem DescriptionA simple mathematical formula for e iswhere n is allowed to go to infinity. This can actually yield very accurate approximations of e using relatively small values of n
#include
int main()
{
int n,b;
double e=2.00,a=1.00;
printf("n e\n");
printf("- -----------\n");
for(n=0;n=2)
{
a=a/n;
e=e+a;
}
if(n==2)
printf("%.1lf\n",e);
else
printf("%.9lf\n",e);
}
//scanf("%*d");
return 0;
}