int Finobiacci(int n){ int a = 0,b = 1; int sum = 0; if (n==0||n==1) { return n;//当n为0或1,返回finobiacci 的值 }else{ for(int i = 0;i<n-1;i++)//采用备忘录的形式实现斐波切纳数的实现 { sum = a + b; a = b; b = sum; } return sum; } }
int Finobiacci(int n){ int a = 0,b = 1; int sum = 0; if (n==0||n==1) { return n;//当n为0或1,返回finobiacci 的值 }else{ for(int i = 0;i<n-1;i++)//采用备忘录的形式实现斐波切纳数的实现 { sum = a + b; a = b; b = sum; } return sum; } }