leetcode 链接:https://leetcode-cn.com/problems/fei-bo-na-qi-shu-lie-lcof/
题目
解答
class Solution {
public int fib(int n) {
if (n < 2) {
return n;
}
int x = 0;
int y = 1;
for (int i = 1; i < n; i++){
y = x + y;
x = y - x;
// 或者:y %= 1000000007;
y = y > 1000000007 ? (y - 1000000007) : y;
}
return y;
}
}