RosettaCodeData/Task/Fibonacci-sequence/LiveCode/fibonacci-sequence.livecode

21 lines
372 B
Plaintext

-- 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