mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-04-27 15:43:58 +00:00
fix fib function for Lua: fib(0) must eql 0 not 1
This commit is contained in:
parent
a7fe2983cc
commit
7938abfe88
@ -87,7 +87,7 @@ until num == 0
|
||||
----------------------------------------------------
|
||||
|
||||
function fib(n)
|
||||
if n < 2 then return 1 end
|
||||
if n < 2 then return n end
|
||||
return fib(n - 2) + fib(n - 1)
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user