用程序实现1!+2!+3!+...+n!
#include <stdio.h>
#include <stdlib.h>
int main(int argc,char *argv[]){
unsigned long sum = 0;
unsigned int jiecheng = 1;
if (argc < 2){
printf("there must be 2 arguments when %s is executed\n",argv[0]);
return -1;
}
int num = atoi(argv[1]);
int i,j;
for(i = num; i >= 1;i--){
j = i;
while(j >= 1) {
jiecheng *= j;
j--;
}
sum += jiecheng;
jiecheng = 1;
}
printf("sum = %lu\n",sum);
return 0;
}