习题2-6 求阶乘序列前N项和
作者:互联网
#include<stdio.h>
double fact(int n);
int main()
{
int i, n;
double result;
scanf("%d", &n);
for(i=1; i<=n; i++){
result = fact(i);
}
printf("%.0f", result);
return 0;
}
double fact(int n)
{
int i, r;
double product;
product=0;
r=1;
for(i=1; i<=n; i++){
r = r*i;
product = product+r;
}
return product;
}
标签:int,double,scanf,序列,阶乘,习题,main 来源: https://www.cnblogs.com/ytmsnzy/p/16587886.html