+
CORE CONCEPT
+
Two parts, always.
+
A recursive function has exactly two things inside it: a base case (when to stop) and a recursive case (how to shrink the problem before calling yourself).
+
+ Rule of thumb. If you can't name the base case out loud, don't write the recursion yet. Draw it on paper first.
+
+
+
Base case
The smallest possible input — one the function answers directly, without calling itself.
e.g. n == 0
+
Recursive case
Every other input — delegate to a smaller version of the same problem.
e.g. n × fact(n-1)
+
+
+