I need some help with some homework. I am not that familiar with python. However, I have some problem with this small python program. It uses recursion to print out a set of number based on the function given. It gets to about num = 30 and the program crashes. Not sure what is wrong or how to fix it. help?
def func(num):
if num==0:
return 0
elif num==1:
return 1
else:
return func(num-1)+2*func(num-2)
for num in range(2,101):
print(num,func(num))
StackOverflowError? Each function call has to allocate a new stack, so you're probably using a lot of resources upon each call.