Recursion: factorial
easy 16 minRecursion is a function solving a problem by calling itself on a smaller copy of it.
Factorial three ways, with input checks and a safe default
Read it, run it, change a line and run it again.
Loading editor…
The recursive version shows the idea; the iterative version is what you ship. Both reject negative input the way math.factorial does.