Factorial 15.5


#1


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


factorial(2) returned 1 instead of 2


I don't see where I went wrong with this.


def factorial(x):
    if x > 1:
        total = 1
        while x > 1:
            total = total * x
            x -= 1
    else:
        return 1
    return x


#4

total contains the factorial number. Yet, you return x:

return x

instead of total


#6

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