I'm pretty sure I did it right, but I get an error message that says - "Oops, try again. Factorial(4) returned 12 instead of 24.

def factorial(x):
    for i in range(x):
        if x > 1:
            product = int(x) * int(x - 1) 
            product = 1
    return product


Well you either return 1 or x*x-1 so in your case 4*(4-1) = 4*3=12.
The idea of factorial is that

n! = n*(n-1)!

meaning instead of x*x-1 you would return x* factorial(x-1).


Agh I can't believe I made such a stupid mistake! Thanks a lot


Would have liked to see someone mention the word recursion here.


Yes the implementation of this is most easily done by a recursion. Do you know that word and just want to mention it or do you want an explanation for it?


I know the word and wanted to mention it.