class Solution { public int Fibonacci(int n) { // write code here return func(n, out _); } public int func(int n, out int temp) { if(n==1 || n==2) { temp=1; return 1; } var pre=func(n-1,out temp); var ans=pre+temp; temp=pre; return ans; } } 斐波那契数列的线性递归版本