Defining Pet Features and Essentials

Mark Wieder mwieder at ahsoftware.net
Wed Feb 12 23:41:13 EST 2014


Geoff-

Close. Your first array element is empty. Right answer, though.

local fibArray

function fib N
    if (N = 1 or N = 2) then
       put 1 into fibArray[N]
       return 1
    end if
    if fibArray[N] is empty then put fib(N-2) + fib(N-1) into fibArray[N]
    return fibArray[N]
 end fib

on mouseUp
    local T
    put empty into field 1
    put the long seconds into T
    get fib(33)
    put it && the long seconds - T
    -- display the array
    repeat with N=1 to 33
       put N & ":" && fibArray[N] & cr after field 1
    end repeat
end mouseUp

-- 
-Mark Wieder
 ahsoftware at gmail.com





More information about the use-livecode mailing list