Skip to content

Recursion · warm-up

Factorial

Write factorial(n) recursively: factorial(0) is 1, and factorial(n) is n * factorial(n - 1).

Run adds print(factorial(5)) after your code, to try it.

Stuck on the idea rather than the code? The Recursion lesson walks through it.