test-lua-speed/speed.lua

17 lines
224 B
Lua
Raw Permalink Normal View History

2024-11-13 20:00:48 +00:00
function Fibonacci(total)
a = 1
b = 1
for n = 0, total do
if n == 0 then
return 0
elseif n == 1 or n == 2 then
return 1
else
c = a + b
a = b
b = c
end
end
return b
end