20 lines
235 B
Go
20 lines
235 B
Go
|
package lua_speed
|
||
|
|
||
|
func Fibonacci(total uint64) uint64 {
|
||
|
a := uint64(1)
|
||
|
b := uint64(1)
|
||
|
for i := range total {
|
||
|
switch i {
|
||
|
case 0, 1:
|
||
|
return i
|
||
|
case 2:
|
||
|
return 1
|
||
|
default:
|
||
|
c := a + b
|
||
|
a = b
|
||
|
b = c
|
||
|
}
|
||
|
}
|
||
|
return b
|
||
|
}
|