-1

I'm new to programming world, and I'm struggling with recursion.

This is my code, but I'm not sure why it doesn't work :(

enter_number = input("enter 'x' value: ")
def g(x):
    if x == 0:
        return 1
    elif x == 1:
        return 2
    else:
        return g(x−1) + g(x−3) + g(x−4)

print(g(enter_number))

thank you

Besttee
  • 25
  • 4

1 Answers1

1

Your g function doesn't handle inputs 2 and 3.

dlask
  • 8,776
  • 1
  • 26
  • 30