文章时效性提示
本文发布于 497 天前,部分信息可能已经改变,请注意甄别。
题目:求1!+2!+3!+…+20!的和
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| #include <stdio.h> unsigned long long Factorial(int input) { if (input>0) { return input*Factorial(input-1); } else return 1; }
unsigned long long Factorial_Sum(int max) { if (max>0) { return Factorial(max)+Factorial_Sum(max-1); } else { return 0; } }
int main() { int max = 20; unsigned long long ret = Factorial_Sum(max); printf("%.0llu",ret); return 0; }
|