Dynamic Programming21 sections · 916 units
Open in Course

Lessons from Factorial

summary

You've now seen recursion in action with factorial. Three key observations:

1.1. The base case (n=0n = 0) stops the recursion. Without it, your program crashes.

2.2. Each recursive call moves closer to the base case (from nn to n1n-1).

3.3. The call stack grows as calls pile up, then shrinks as they return. These patterns repeat in every recursive solution. See them early, and writing recursive code becomes predictable.

unnamed (6) (1).jpg