22 lines
No EOL
436 B
Python
22 lines
No EOL
436 B
Python
# Fibonacci number generator in Python using recursion
|
|
import time
|
|
|
|
COUNT = 30
|
|
|
|
def fibo(i):
|
|
if i <= 1:
|
|
return i
|
|
else:
|
|
return(fibo(i-1) + fibo(i-2))
|
|
|
|
def main():
|
|
print("Lasketaan fibo: %d" % COUNT)
|
|
start_time = time.time()
|
|
|
|
for x in range(COUNT):
|
|
print("Fibo: %2d = %d" %(x, fibo(x)))
|
|
|
|
print("Laskenta kesti %.5f sec" % (time.time() - start_time))
|
|
|
|
if __name__ == '__main__':
|
|
main() |