I am new to Python and would like to know if recursion works at all. I can't get my code running. It is supposed to print all the the fibonacci numbers:
#!/usr/bin/python
import time, sys
def calc_fib_num(n):
if (n >= 2):
return calc_fib_num(n-1) + calc_fib_num(n-2)
elif (n == 1):
return 1
else:
return 0
print "0",
print "1",
for n in range(2,20):
fib_num = calc_fib_num(n)
print fib_num