1131: 零起点学算法38——求阶乘和
Time Limit: 1 Sec Memory Limit: 64 MB 64bit IO Format: %lldSubmitted: 2719 Accepted: 1736
[ Submit ][ Status ][ Web Board ]
Description
输入一个正整数n(n<=10),计算
S=1!+2!+3!+...+n!
Input
输入一个正整数n(n<=10)(多组数据)
Output
输出S(每组数据一行)
Sample Input
2
Sample Output
3
Source
零起点学算法
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 }
查看更多关于1131: 零起点学算法38——求阶乘和的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did238275