leet-code/fibonacci-number/sol.go

10 lines
143 B
Go
Raw Normal View History

2022-07-06 20:05:27 +00:00
package main
func fib(n int) int {
current, next := 0, 1
for i := 0; i < n; i++ {
current, next = next, current+next
}
return current
}