Forgive me, I'm new, but I want to build a recursive function that takes a natural number and returns the product of all the natural numbers from 1 up to the given number. So factorial(5) should return 120 (5·4·3·2·1 = 120). However, I think I am just stuck. Here is what I have so far:
def factorial(x):
"""returns the product of all natural numbers from 1 up to the given number
natural number -> natural number"""
if x <= 0:
return 1
else:
return x*(x-1)
Would the best route be to implement a counter?