递归求阶乘和

https://pintia.cn/problem-sets/12/problems/352

 1 double fact(int n)
 2 {
 3     double product;
 4     if (n == 0)
 5     {
 6         product = 1;
 7     }
 8     else
 9     {
10         product = n * fact(n - 1);
11     }
12 
13     return product;
14 }
15 double factsum(int n)
16 {
17     double result = 0;
18     for (int i = 1; i <= n; i++)
19     {
20         result = result + fact(i);
21     }
22 
23     return result;
24 }
原文地址:https://www.cnblogs.com/2018jason/p/12233353.html