RosettaCodeData/Task/Leonardo-numbers/Pluto/leonardo-numbers.pluto
2026-04-30 12:34:36 -04:00

18 lines
525 B
Text

require "table2"
local fmt = require "fmt"
local function leonardo(first, add, limit)
local leo = table.rep(limit, 0)
leo[1] = first[1]
leo[2] = first[2]
for i = 3, limit do
leo[i] = leo[i - 1] + leo[i - 2] + add
end
return leo
end
print("The first 25 Leonardo numbers with L(0) = 1, L(1) = 1 and Add = 1 are:")
fmt.tprint("%6d", leonardo({1, 1}, 1, 25), 10)
print("\n\nThe first 25 Leonardo numbers with L(0) = 0, L(1) = 1 and Add = 0 are:")
fmt.tprint("%6d", leonardo({0, 1}, 0, 25), 10)