RosettaCodeData/Task/Fibonacci-sequence/LiveCode/fibonacci-sequence.livecode
2016-12-05 23:44:36 +01:00

20 lines
372 B
Text

-- Iterative, translation of the basic version.
function fibi n
put 0 into aa
put 1 into b
repeat with i = 1 to n
put aa + b into temp
put b into aa
put temp into b
end repeat
return aa
end fibi
-- Recursive
function fibr n
if n <= 1 then
return n
else
return fibr(n-1) + fibr(n-2)
end if
end fibr