#include<stdio.h>
unsigned long Fact(unsigned int n);
main()
{
int m,k;
unsigned long p=0;
scanf("%d",&m);
for(k=1;k<=m;k++)
{
p+=Fact(k);
}
printf("p=%lu\n",p);
return 0;
}
unsigned long Fact(unsigned int n)
{
unsigned int i;
unsigned long result=1;
for(i=2;i<=n;i++)
result*=i;
return result;
}
这个代码运行结果为
知识点
1.函数调用
2.for循环
心得
1.学会运用函数调用