C语言编程:计算并输出下列多项式的值 F(m)=1+1/(1!)+1/(2!)+.....+1/(m!)
C语言编程:计算并输出下列多项式的值 F(m)=1+1/(1!)+1/(2!)+.....+1/(m!)
日期:2017-08-21 17:01:36 人气:2
#includedouble fac(int n){if(n==0)return 1.0; return n*fac(n-1);}int main(){int i,m; double s=0; scanf("%d",&m); for(i=0;i<m+1;i++) s+=1.0/fac(i); printf("%.16lf\n",s); return 0;}