输入一个正整数n(n<=10),计算
S=1!+2!+3!+...+n!
标签:problems 分享 arc inpu ret style can image ext
输入一个正整数n(n<=10),计算
S=1!+2!+3!+...+n!
输入一个正整数n(n<=10)(多组数据)
输出S(每组数据一行)
2
3
1 #include<stdio.h> 2 int main(){ 3 int n; 4 while(scanf("%d",&n)!=EOF){ 5 long long s=0; 6 for(int i=1;i<=n;i++){ 7 long long sum=1; 8 for(int j=i;j>0;j--){ 9 sum*=j; 10 } 11 s+=sum; 12 } 13 printf("%lld\n",s); 14 } 15 return 0; 16 }
标签:problems 分享 arc inpu ret style can image ext
原文地址:http://www.cnblogs.com/dddddd/p/6680406.html