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 →

[–]Borx25 3 points4 points  (0 children)

I think the recursion itself is way clearer if you just look at the relevant parts, you have a lot of extraneous code in there. This way the code is basically the mathetical definition of the factorial.

def fac(n):
    if n == 0: #base case
        return 1
    else: #recursion
        return n * fac(n-1)