how do i do this?:
Define a function factorial that takes an integer x as input.

Calculate and return the factorial of that number.


The forum is to help you, not code for you.

How do think you could tackle this problem? Maybe create a variable to store the result? A loop for all the multiplications? Please post your code so we can help you


def factorial(x):
return x * x - 1


lets say x is 5, we want to return 120 (5*4*3*2*1)

your function would return 20.

You will need to create a total variable (give it a value of 1), then add a loop, to get all the values from x till 1, each time multiplying it with total to get to return, for example, 120 if x is 5

note: 5 is just an example, the exercise will test multiply values


so is factorial(x-1) the iterator for this loop? That's the only way it makes sense to me.


nope, but you could use a recursive function call to solve this problem. Or include a while or a for loop


def factorial(x):
if x==0:
return 1
return x*factorial(x-1)