刚那个程序有点问题 做的太快了!#include<stdio.h>
void main()
{
double jiecheng(int n);
double result;
int x;
printf("please input a number from 3 to 20 :\n");
scanf("%d",&x);
if(x<3 || x>20)
printf("error !");
else
{
result=jiecheng(x);
printf("the result is : %f",result);
}
}
double jiecheng( int n)
{
double s=1;
int i;
double sum=0;
for(i=1;i<=n;i++)
{s=s*i;
sum=sum+s;
};
return sum;
}