You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
fibLoop := method(n,
|
|
prev := 1;
|
|
result := 0;
|
|
while(n > 0,
|
|
n = n - 1;
|
|
temp := result
|
|
result = prev + result
|
|
prev = temp
|
|
)
|
|
|
|
result
|
|
)
|
|
|
|
fibLoop(30) println
|
|
|
|
# time of fibLoop(30)
|
|
# real 0m0.047s
|
|
# user 0m0.041s
|
|
# sys 0m0.004s
|
|
|
|
|