1013阶层求和

 1 //这个题目相当的操蛋,非常长的数字也要考虑进去
 2 
 3 #include "stdafx.h"
 4 
 5 long long  fact(int x)
 6 {
 7     long long sum=1;
 8     if (x==1||x==0)
 9         return 1;
10 
11     for (int i = 1; i < x + 1; i++)
12         sum *= i;
13     return sum+fact(x - 1);
14     
15 
16 }
17 
18 int main()
19 {
20     int n;
21     scanf_s("%d", &n);
22     printf("%lld", fact(n));
23     return 0;
24 }

 

posted @ 2018-07-18 17:13  kongchung  阅读(115)  评论(0编辑  收藏  举报