19 lines
373 B
Plaintext
19 lines
373 B
Plaintext
local fn Fibonacci( n as NSInteger ) as NSInteger
|
|
NSInteger result
|
|
if n < 2 then result = n : exit fn
|
|
result = fn Fibonacci( n-1 ) + fn Fibonacci( n-2 )
|
|
end fn = result
|
|
|
|
window 1
|
|
|
|
NSInteger i
|
|
CFTimeInterval t
|
|
|
|
t = fn CACurrentMediaTime
|
|
for i = 0 to 40
|
|
print i;@".\t";fn Fibonacci(i)
|
|
next
|
|
print : printf @"Compute time: %.3f ms",(fn CACurrentMediaTime-t)*1000
|
|
|
|
HandleEvents
|