5/15 Factorial


#1

Hey im stuck on this one part, what exactly am i doing wrong with my code?

def factorial(x):
    factorial_x = [x]
    while x > 1:
        reduced_x = x - 1
        factorial_x.append(reduced_x)
    for num in factorial_x:
        product_x = 1*num
    return product_x

#2

x should always be greater than one, as you never decrement it.

Also,

As you have declared these variables inside of loops, their values will 'reset' each time the loop runs.

I would highly recommend doing this exercise with a range(). :slightly_smiling: