leetcode 链接:
https://leetcode.cn/problems/fei-bo-na-qi-shu-lie-lcof/soluti…
解题思路:
递归
func fib(n int) int {
if n == 0 || n == 1 {return n}
a,b := 0, 1
for i := 2; i <= n; i++ {a, b = b, (a+b) % 1000000007
}
return b
}
leetcode 链接:
https://leetcode.cn/problems/fei-bo-na-qi-shu-lie-lcof/soluti…
解题思路:
递归
func fib(n int) int {
if n == 0 || n == 1 {return n}
a,b := 0, 1
for i := 2; i <= n; i++ {a, b = b, (a+b) % 1000000007
}
return b
}