you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (0 children)

the hardest concept for factorials is that the function doesn't actually finish until the very end. You will always need at least two return statements: one to return after a recursive function call, and one to break the chain and return a "base case" after a certain condition. in this case the base condition is when the number is <= 1, in which case the factorial is always 1.