31 lines
482 B
Plaintext
31 lines
482 B
Plaintext
include "Tlbx Timer.incl"
|
|
include "ConsoleWindow"
|
|
|
|
local fn Fibonacci( n as long ) as Long
|
|
begin globals
|
|
dim as long s1, s2// static
|
|
end globals
|
|
|
|
dim as long temp
|
|
|
|
if ( n < 2 )
|
|
s1 = n
|
|
exit fn
|
|
else
|
|
temp = s1 + s2
|
|
s2 = s1
|
|
s1 = temp
|
|
exit fn
|
|
end if
|
|
end fn = s1
|
|
|
|
dim as long i
|
|
dim as UnsignedWide start, finish
|
|
|
|
Microseconds( @start )
|
|
for i = 0 to 40
|
|
print i; ". "; fn Fibonacci(i)
|
|
next i
|
|
Microseconds( @finish )
|
|
print "Compute time:"; (finish.lo - start.lo ) / 1000; " ms"
|