Pattern Recognition Drill
Easy Recursion
The Problem
Compute n! recursively.
What approach would you use?
Think about it before scrolling down.
Multiply n * factorial(n-1). Base case: return 1. O(n) time, O(n) stack space.
Common Trap
Iterative loop is simpler and uses O(1) space. But this drill practices recursion.