递归求Fabonacci数列
https://pintia.cn/problem-sets/12/problems/356
1 int f(int n) 2 { 3 int ret; 4 5 if (n == 0) 6 { 7 ret = 0; 8 } 9 else if (n == 1) 10 { 11 ret = 1; 12 } 13 else 14 { 15 ret = f(n - 1) + f(n - 2); 16 } 17 18 return ret; 19 }
https://pintia.cn/problem-sets/12/problems/356
1 int f(int n) 2 { 3 int ret; 4 5 if (n == 0) 6 { 7 ret = 0; 8 } 9 else if (n == 1) 10 { 11 ret = 1; 12 } 13 else 14 { 15 ret = f(n - 1) + f(n - 2); 16 } 17 18 return ret; 19 }