Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,30 @@
|
|||
window 1, @"Fibonacci Sequence", (0,0,480,620)
|
||||
|
||||
local fn Fibonacci( n as long ) as long
|
||||
static long s1
|
||||
static long s2
|
||||
long temp
|
||||
|
||||
if ( n < 2 )
|
||||
s1 = n
|
||||
exit fn
|
||||
else
|
||||
temp = s1 + s2
|
||||
s2 = s1
|
||||
s1 = temp
|
||||
exit fn
|
||||
end if
|
||||
end fn = s1
|
||||
|
||||
long i
|
||||
CFTimeInterval t
|
||||
|
||||
t = fn CACurrentMediaTime
|
||||
|
||||
for i = 0 to 40
|
||||
print i;@".\t";fn Fibonacci(i)
|
||||
next i
|
||||
|
||||
print : printf @"Compute time: %.3f ms",(fn CACurrentMediaTime-t)*1000
|
||||
|
||||
HandleEvents
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue