题目链接
思路
递推,思路可以参考剑指 Offer 10- II. 青蛙跳台阶问题
代码
class Solution {
public int fib(int n) {
int a = 0;
int b = 1;
int sum;
for(int i = 0; i < n; i++){
sum = (a + b) % 1000000007;
a = b;
b = sum;
}
return a;
}
}
标签:10,Offer,int,sum,斐波,那契
From: https://www.cnblogs.com/shixuanliu/p/17195939.html