C语言编程:Y=1+1/1!+1/2!+1/3!+……1/10!
C语言编程:Y=1+1/1!+1/2!+1/3!+……1/10!
日期:2010-06-18 21:27:27 人气:1
#include
float jie(float n)
{
float i,s=1;
for (i=1;i<n+1;i++)
{
s=s*i;
}
return s;
}
void main()
{
float y=0,i;
for (i=0;i<10;i++)
{
y=y+1/jie(i);
}
printf("%f\n",y);
}
运行结果是
2.718282