I want to write a function in Python which takes an integer, then returns the number of combinations the given integer can be added to with the numbers 3, 2, and 1.
For example, if I call the function with the number 2, I would get the response of 2, since there are two combinations of 3, 2 and 1 to get to 2: 1,1 and 2.
Any advice on how to go about this?
Here's what I have coded:
def countStairs(n):
if n == 0:
print(number)
elif n == 2:
return countStairs(n-1)
return countStairs(n-2)
number = number + 1
elif n == 1:
return countStairs(n-1)
number = number + 1
else:
return countStairs(n-3)
number = number + 1