第一次发帖 修改4楼的
#include <stdio.h>
double jiecheng(int i);
int main(void)
{
int i,n;
double sum=0;
printf("please input the number n:");
scanf("%d",&n);
if(n==1||n==0)
{printf("%d!=1.000000",n);
return 0; }
else if(n==2)
{printf("%d!=3.000000\n",n); return 0;}
for (i=1;i<=n;i++)
sum+=jiecheng(i);
printf("1!+2!+.....+%d!=%lf\n",n,sum);
return 0;
}
double jiecheng(int i)
{
int j;
double sum=1;
for (j=1;j<=i;j++)
sum*=j;
return sum;
}