Files
flenser/js4g/fib.py
ADAM David Alan Martin a3dc7e980e Significant speed improvements.
By not cloning code for recursion directly into the processing
buffer and by not copying as many strings and by not doing
string->int conversions all the time, it's significantly faster.

Specifically, it's about 5.5x slower than Python.
2025-09-16 17:21:29 -04:00

18 lines
226 B
Python

def fib( a ):
if a == 0:
return 0
elif a == 1:
return 1
else:
return fib( a - 1 ) + fib( a - 2 )
def do_fibs( cnt ):
if cnt > 0:
do_fibs( cnt - 1 )
print( fib( cnt ) )
else:
print( fib( 0 ) )
do_fibs( 38 )