test-lua-speed/go-speed.go

20 lines
235 B
Go
Raw Normal View History

2024-11-13 20:00:48 +00:00
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
}