← DFS / Recursion

Pattern Recognition Drill

#48 — Factorial

Easy Recursion

The Problem

Compute n! recursively.

What approach would you use?

Think about it before scrolling down.

Key Signals

DFS / Recursion

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.

← #47 #49 →