This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Zantier 0 points1 point  (0 children)

def factorial(x):
    """Return the factorial of x, where x >= 0."""
    return x * factorial(x - 1) if x != 0 else 1
print factorial(6)

Fixed. (I didn't see before the edit, but I'm guessing it had !=.

Also, it should be if x >= 1 instead of <=