```
how do i do this?:
Define a function factorial that takes an integer x as input.
Calculate and return the factorial of that number.
```

# 5.factorial

**talleh**#1

**stetim94**#2

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

**stetim94**#4

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

**pcdreams**#7

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

**stetim94**#9

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