Quant Memo
Core

Tribonacci Numbers and Tiling Counts

The Tribonacci sequence extends Fibonacci's 'sum of the last two' rule to 'sum of the last three,' and it is the natural answer to counting problems where each step can be one of three sizes instead of two.

The Fibonacci sequence answers "how many ways can I climb nn stairs taking 1 or 2 steps at a time?" — each count is the sum of the two before it. The Tribonacci sequence answers the same question when you're also allowed to take 3 steps at once: each term is the sum of the three preceding terms, Tn=Tn1+Tn2+Tn3T_n = T_{n-1} + T_{n-2} + T_{n-3}, because your last move onto stair nn was a step of size 1, 2, or 3, landing you from stair n1n-1, n2n-2, or n3n-3 respectively.

With seeds T0=0T_0 = 0, T1=1T_1 = 1, T2=1T_2 = 1, the sequence runs 0,1,1,2,4,7,13,24,44,0, 1, 1, 2, 4, 7, 13, 24, 44, \ldots. Check T6=T5+T4+T3=13+7+4=24T_6 = T_5 + T_4 + T_3 = 13 + 7 + 4 = 24 — matching the table.

The same recursion counts tilings: the number of ways to tile a 1×n1 \times n strip using tiles of length 1, 2, and 3 follows exactly this rule, since the last tile placed has one of those three lengths. Interview variants dress this up as step-counting, tiling, or "how many binary strings of length nn avoid three consecutive identical digits" — all reduce to the same three-term recursion once you identify what the "last move" could have been.

Whenever a counting problem's last step can take one of three sizes, the count satisfies a three-term recursion (Tribonacci-style): the total ways to reach nn is the sum of the ways to reach n1n-1, n2n-2, and n3n-3.

Related concepts

Practice in interviews

Further reading

  • Concrete Mathematics, Graham, Knuth & Patashnik
ShareTwitterLinkedIn