Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
9
Task/Fibonacci-sequence/Lua/fibonacci-sequence-5.lua
Normal file
9
Task/Fibonacci-sequence/Lua/fibonacci-sequence-5.lua
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
-- table recursive done properly (values are actually saved into table;
|
||||
-- also the first element of Fibonacci sequence is 0, so the initial table should be {0, 1}).
|
||||
fib_n = setmetatable({0, 1}, {
|
||||
__index = function(t,n)
|
||||
if n <= 0 then return 0 end
|
||||
t[n] = t[n-1] + t[n-2]
|
||||
return t[n]
|
||||
end
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue