I'm trying to build a function that will take in a number and then use recursion to print out a Fibonacci sequence and end the sequence on the number. So if I have a sequence that starts on 0 and 1 if the users input is 4 it will return 0,1,1,2,3. I am getting this RecursionError:
RecursionError: maximum recursion depth exceeded while calling a Python object
This is my code:
num = input("Give me a number.")
def fib(n):
n = int(n)
if n == 0:
return 1
return fib(n - 1) + fib(n - 2)
print(fib(num))