5. Factorial Help Required


#1

Why is my code not working? It gives the correct answer every time I modify x. For example, when x is 4, it returns/prints 10.

https://www.codecademy.com/en/courses/python-intermediate-en-rCQKw/0/5?curriculum_id=4f89dab3d788890003000096#


def factorial(x):
    total=0
    for i in range(1, x+1):
        total += i
    return total
        
        
print factorial(4)


#2

Please disregard my post above. I misunderstood what a factorial was. Thought it added each time instead of muliply.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.