Where Fibonacci Numbers Show Up
Why counting puzzles about tilings, staircases, and 'no two in a row' constraints keep producing the Fibonacci sequence, and how to recognize the pattern fast in an interview.
Prerequisites: Mathematical Induction, How to Crack a What-Comes-Next Question
"How many ways can you climb a staircase of steps if you take one or two steps at a time?" is one of the most-repeated counting questions in interviews, and it isn't really about staircases — it's the Fibonacci sequence wearing a costume. Recognizing that a counting problem has this shape lets you write down the answer's recurrence in seconds instead of enumerating cases.
Why the same recurrence keeps appearing
The staircase problem has a clean recursive argument: to reach step , your last move was either a single step from step , or a double step from step . Every valid path falls into exactly one of these two groups, and they don't overlap, so the total count is
In plain English: the number of ways to finish is the number of ways to finish one step early (then take a single step) plus the number of ways to finish two steps early (then take a double step). With and , this generates — the Fibonacci sequence, just shifted by an index. The exact same argument reappears any time a puzzle asks you to build a sequence out of pieces of size 1 and 2 with no other constraint: tiling a strip with and tiles, or counting binary strings of length with no two consecutive 1s.
Worked example: tiling a 1×n strip
How many ways can you tile a strip using squares and dominoes? Let be the count for a strip of length . The tile covering the last cell is either a square (leaving a strip to tile) or the right half of a domino (leaving a strip). So , with (empty strip, one way — do nothing) and . Building up: . There are 34 ways to tile the strip — and you found it by adding two numbers seven times, not by drawing tilings.
Worked example: no two consecutive 1s
How many binary strings of length 5 have no two consecutive 1s? Let count valid strings of length . If the string ends in 0, the first characters form any valid string of length . If it ends in 1, the character before it must be 0 (to avoid "11"), so the first characters form any valid string of length . Hence , with (0 or 1) and (00, 01, 10). That gives — 13 valid strings of length 5.
What this means in practice
Once you spot a "last piece has two options, and the two resulting sub-problems are disjoint and smaller" structure, you can skip straight to writing and reading off a table, which is both faster and less error-prone than direct enumeration. The same shape underlies simple combinatorial models of order-arrival patterns and coin-flip streaks in quant interviews — anywhere the last unit of "space" can be filled in exactly two mutually exclusive ways.
Any counting problem where the last element has two mutually exclusive, appropriately-sized options — and the remaining sub-problem is strictly smaller — reduces to , the Fibonacci recurrence. Spotting this shape turns enumeration into a short table.
Related concepts
Practice in interviews
Further reading
- Graham, Knuth, Patashnik, Concrete Mathematics, ch. 6