Fibonacci number generator in ANSI C, Python and Java using recursion
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

22 lines
436 B

# 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()