Base Case
Domain: Programming Fundamentals
π― Motivation
Recursion needs a stopping point - without it, the function calls itself forever. The base case is that stop.
π Concrete Example
In factorial(n), the base case is if n <= 1: return 1. Without this, factorial(0) calls factorial(-1) calls factorial(-2)β¦ forever.
π Analogy
The smallest nesting doll that doesnβt open - itβs solid inside. When you reach it, you stop opening. Thatβs the base case.