1.Base case and recursive case
Every recursive function needs a base case that returns directly, with no further recursive call, and a recursive case that calls itself on a smaller version of the same problem — the base case is what stops the calls.
Key features
- Every recursive call must move the input strictly closer to a base case — the same size (or a bigger) input recurses forever
- A function can have more than one base case (e.g. both n == 0 and a guard for negative input)
- Forgetting the base case, or writing one that is never actually reached, causes infinite recursion — Python turns that into a RecursionError, not a silent infinite loop
A base case only stops recursion if every recursive call actually moves the input closer to it — a base case that is never reached is no different from having none at all.