Math Fundamentals18 sections · 814 units
Open in Course

Climbing Stairs - Insight

Recursive structure

To reach step nn, you must come from step n1n-1 (taking 1 step) or step n2n-2 (taking 2 steps). So ways(n)=ways(n1)+ways(n2)ways(n) = ways(n-1) + ways(n-2).

This is the Fibonacci recurrence. Base cases: ways(1)=1ways(1) = 1, ways(2)=2ways(2) = 2. The sum rule applies because reaching from n1n-1 and from n2n-2 are mutually exclusive paths.