https://leetcode-cn.com/problems/fei-bo-na-qi-shu-lie-lcof/
func fib(n int) int {
var m int64 = 1000000007
if n == 0 {
return 0
}
if n == 1 {
return 1
}
if n ==2 {
return 1
}
var r, a, b int64
a = 1
b = 1
for i := 2; i < n; i++ {
r = a + b
a = b
b = r
}
return int(r % m)
}
0 <= n <= 100
原创文章,作者:sunnyman218,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/244622.html