Chapter

Recursion and Sequences

The module teaches recurrences by last step, last tile, last symbol, and last point of a path, and introduces extra states.
Log in to track solved progress and bookmarks.

Theory

Key Idea

Recursion appears when an object can be built from a smaller object by its last step. Instead of counting the large case at once, define \(a_n\) as the number of ways for size \(n\), then express \(a_n\) through previous values.

In olympiad problems, the point is not to guess a sequence, but to justify the split: by the last step, last tile, last symbol, last column, or last point of a path.

Basic Facts

  • If the last step has length \(1\) or \(2\), the recurrence \(a_n=a_{n-1}+a_{n-2}\) often appears.
  • Tilings of a \(2\times n\) strip by dominoes give the same Fibonacci recurrence.
  • Binary strings with no adjacent ones are naturally split by the last symbol.
  • Grid paths satisfy \(P(i,j)=P(i-1,j)+P(i,j-1)\), or can be counted by \(\binom{m+n}{m}\).
  • If one state is not enough, introduce extra states, such as “a board with one missing corner on the right”.

When to Use This Method

  • You need to count ways for a long string, strip, staircase, or path.
  • An object of size \(n\) naturally ends in one of several types of last steps.
  • Small cases are easy to list, and the general case resembles previous ones.
  • Direct enumeration grows quickly, but the structure repeats.

How to Recognise the Method

Ask: what can the last step look like? If that last step is removed, what remains? If it is the same kind of problem, one recurrence may be enough. If several “almost the same” problems remain, use several states.

For strings, look at the last symbol or last two symbols. For tilings, look at the last column. For paths, look at where the path came from before the final point.

Typical Mistakes

  • Writing a recurrence without initial conditions.
  • Counting objects twice because the last-step cases overlap.
  • Not checking small values \(n=0\), \(n=1\), although the recurrence needs them.
  • Using a Fibonacci recurrence when there is a third type of last step.
  • In path problems, confusing the number of steps with the number of grid points.

Mini-Checklist

  • What does \(a_n\) mean?
  • Which initial values are needed?
  • By which final element do we split cases?
  • Are the cases disjoint?
  • Are all possibilities included?
  • Do we need a second state?

Examples

Example 1. Stairs

The last step immediately gives a Fibonacci recurrence.

Problem. In how many ways can one climb \(7\) stairs if each move is \(1\) or \(2\) stairs?

Solution.

Let \(a_n\) be the number of ways to climb \(n\) stairs. The last move was either \(1\) stair from \(n-1\), or \(2\) stairs from \(n-2\). Therefore \(a_n=a_{n-1}+a_{n-2}\). Initial values: \(a_0=1\), \(a_1=1\). Thus \(a_2=2\), \(a_3=3\), \(a_4=5\), \(a_5=8\), \(a_6=13\), \(a_7=21\).

Example 2. A \(2\times n\) Strip

Domino tilings have the same structure.

Problem. In how many ways can a \(2\times6\) board be tiled by dominoes?

Solution.

Let \(a_n\) be the number of tilings of \(2\times n\). The last column is either covered by a vertical domino, leaving \(2\times(n-1)\), or the last two columns are covered by two horizontal dominoes, leaving \(2\times(n-2)\). Hence \(a_n=a_{n-1}+a_{n-2}\), with \(a_0=1\), \(a_1=1\). We get \(a_6=13\).

Example 3. Binary Strings

Strings are naturally split by the last symbol.

Problem. How many binary strings of length \(6\) contain no two adjacent ones?

Solution.

Let \(a_n\) be the number of such strings of length \(n\). If the string ends in \(0\), before it there may be any valid string of length \(n-1\). If it ends in \(1\), the previous symbol must be \(0\), and before that there is a valid string of length \(n-2\). Hence \(a_n=a_{n-1}+a_{n-2}\). With \(a_0=1\), \(a_1=2\), we get \(a_6=21\).

Example 4. Grid Paths

The last step into a point comes from the left or from below.

Problem. How many shortest paths go from \((0,0)\) to \((4,3)\), if only right and up moves are allowed?

Solution.

One must make \(4\) right moves and \(3\) up moves, \(7\) moves total. Choose the positions of the \(4\) right moves: \(\binom{7}{4}=35\).

Example 5. A Path Through a Point

Sometimes a path splits into two independent parts.

Problem. How many shortest paths from \((0,0)\) to \((5,4)\) pass through \((2,1)\)?

Solution.

To reach \((2,1)\), one needs \(2\) right moves and \(1\) up move: \(\binom{3}{1}=3\) paths. From \((2,1)\) to \((5,4)\), one needs \(3\) right and \(3\) up moves: \(\binom{6}{3}=20\) paths. Total: \(3\cdot20=60\).

Example 6. Compositions

Splitting by the last summand gives a recurrence with three previous terms.

Problem. In how many ways can \(8\) be represented as a sum of \(1\), \(2\), and \(3\), if order matters?

Solution.

Let \(a_n\) be the number of ways to get sum \(n\). The last summand is \(1\), \(2\), or \(3\), so \(a_n=a_{n-1}+a_{n-2}+a_{n-3}\). With \(a_0=1\), \(a_1=1\), \(a_2=2\), we get \(a_3=4\), \(a_4=7\), \(a_5=13\), \(a_6=24\), \(a_7=44\), \(a_8=81\).

Example 7. Forbidden Three Zeros

Sometimes one must look at the final block.

Problem. How many binary strings of length \(7\) contain no three consecutive zeros?

Solution.

Let \(a_n\) be the number of such strings. A valid string ends in \(1\), \(01\), or \(001\), according to the final block of zeros before the last one; for string endings this gives the recurrence \(a_n=a_{n-1}+a_{n-2}+a_{n-3}\). Initial values: \(a_0=1\), \(a_1=2\), \(a_2=4\). Thus \(a_7=81\).

Example 8. An Extra State

For a harder tiling, one variable is no longer enough.

Problem. A \(2\times n\) board is tiled by dominoes and L-trominoes. Explain why a second state is useful.

Solution.

Let \(A_n\) be the number of full tilings of \(2\times n\), and let \(B_n\) be the number of tilings of a \(2\times n\) board with one right corner cell removed. The last block may create or fill such a “gap”, giving recurrences \(B_n=A_{n-2}+B_{n-1}\), \(A_n=A_{n-1}+A_{n-2}+2B_{n-1}\). The second state is needed because after removing an L-tromino, what remains is often not a rectangle but an almost-rectangle.

Problems

Problems

#10.1
#10.1

Five Stairs

Fibonacci Grade 7 Grade 8 ★☆☆☆☆

In how many ways can one climb \(5\) stairs if each move is \(1\) or \(2\) stairs?

Details
Problem: COM-B1-M10-P001
Difficulty: Level 1 of 5
Tag: Fibonacci
Grade: Grade 7, Grade 8
#10.2
#10.2

A \(2\times4\) Board

Tiling Grade 7 Grade 8 ★☆☆☆☆

In how many ways can a \(2\times4\) board be tiled by dominoes?

Details
Problem: COM-B1-M10-P002
Difficulty: Level 1 of 5
Tag: Tiling
Grade: Grade 7, Grade 8
#10.3
#10.3

Strings of Length \(4\)

Binary strings Grade 7 Grade 8 ★☆☆☆☆

How many binary strings of length \(4\) contain no two adjacent ones?

Details
Problem: COM-B1-M10-P003
Difficulty: Level 1 of 5
Tag: Binary strings
Grade: Grade 7, Grade 8
#10.4
#10.4

Path \((0,0)\to(2,3)\)

Counting Grade 7 Grade 8 ★☆☆☆☆

How many shortest paths go from \((0,0)\) to \((2,3)\), if only right and up moves are allowed?

Details
Problem: COM-B1-M10-P004
Difficulty: Level 1 of 5
Tag: Counting
Grade: Grade 7, Grade 8
#10.5
#10.5

Sixth Term

Recursion Grade 7 Grade 8 ★☆☆☆☆

A sequence is defined by \(a_1=1\), \(a_2=2\), \(a_n=a_{n-1}+a_{n-2}\). Find \(a_6\).

Details
Problem: COM-B1-M10-P005
Difficulty: Level 1 of 5
Tag: Recursion
Grade: Grade 7, Grade 8
#10.6
#10.6

Ten Stairs

Fibonacci Grade 7 Grade 8 ★★☆☆☆

In how many ways can one climb \(10\) stairs using steps of \(1\) or \(2\)?

Details
Problem: COM-B1-M10-P006
Difficulty: Level 2 of 5
Tag: Fibonacci
Grade: Grade 7, Grade 8
#10.7
#10.7

A \(2\times8\) Board

Tiling Grade 7 Grade 8 ★★☆☆☆

In how many ways can a \(2\times8\) board be tiled by dominoes?

Details
Problem: COM-B1-M10-P007
Difficulty: Level 2 of 5
Tag: Tiling
Grade: Grade 7, Grade 8
#10.8
#10.8

Strings of Length \(8\)

Binary strings Grade 7 Grade 8 ★★☆☆☆

How many binary strings of length \(8\) contain no two adjacent ones?

Details
Problem: COM-B1-M10-P008
Difficulty: Level 2 of 5
Tag: Binary strings
Grade: Grade 7, Grade 8
#10.9
#10.9

Path \((0,0)\to(4,3)\)

Binomial coefficients Grade 7 Grade 8 ★★☆☆☆

How many shortest paths go from \((0,0)\) to \((4,3)\)?

Details
Problem: COM-B1-M10-P009
Difficulty: Level 2 of 5
Tag: Binomial coefficients
Grade: Grade 7, Grade 8
#10.10
#10.10

Path Through a Point

Product rule Grade 8 Grade 9 ★★☆☆☆

How many shortest paths from \((0,0)\) to \((5,4)\) pass through \((2,1)\)?

Details
Problem: COM-B1-M10-P010
Difficulty: Level 2 of 5
Tag: Product rule
Grade: Grade 8, Grade 9
#10.11
#10.11

Strip of \(9\) Cells

Tiling Grade 8 Grade 9 ★★☆☆☆

In how many ways can a \(1\times9\) strip be tiled by \(1\times1\) and \(1\times2\) tiles?

Details
Problem: COM-B1-M10-P011
Difficulty: Level 2 of 5
Tag: Tiling
Grade: Grade 8, Grade 9
#10.12
#10.12

No Consecutive Numbers

Subsets Grade 8 Grade 9 ★★☆☆☆

How many subsets of \(\{1,2,\ldots,7\}\) contain no two consecutive numbers?

Details
Problem: COM-B1-M10-P012
Difficulty: Level 2 of 5
Tag: Subsets
Grade: Grade 8, Grade 9
#10.13
#10.13

Subsets Without Neighbors

Subsets Grade 8 Grade 9 ★★★☆☆

Prove that the number of subsets of \(\{1,2,\ldots,n\}\) containing no two consecutive numbers satisfies \(a_n=a_{n-1}+a_{n-2}\).

Details
Problem: COM-B1-M10-P013
Difficulty: Level 3 of 5
Tag: Subsets
Grade: Grade 8, Grade 9
#10.14
#10.14

Prove the Domino Recurrence

Tiling Grade 8 Grade 9 ★★★☆☆

Prove that the number of domino tilings of a \(2\times n\) board satisfies \(a_n=a_{n-1}+a_{n-2}\).

Details
Problem: COM-B1-M10-P014
Difficulty: Level 3 of 5
Tag: Tiling
Grade: Grade 8, Grade 9
#10.15
#10.15

No Three Zeros

Binary strings Grade 8 Grade 9 ★★★☆☆

How many binary strings of length \(10\) contain no three consecutive zeros?

Details
Problem: COM-B1-M10-P015
Difficulty: Level 3 of 5
Tag: Binary strings
Grade: Grade 8, Grade 9
#10.16
#10.16

Path Avoiding a Point

Complement method Grade 8 Grade 9 ★★★☆☆

How many shortest paths from \((0,0)\) to \((5,4)\) do not pass through \((2,1)\)?

Details
Problem: COM-B1-M10-P016
Difficulty: Level 3 of 5
Tag: Complement method
Grade: Grade 8, Grade 9
#10.17
#10.17

Parts \(1,2,3\)

Recursion Grade 8 Grade 9 ★★★☆☆

In how many ways can \(9\) be represented as a sum of \(1\), \(2\), and \(3\), if order matters?

Details
Problem: COM-B1-M10-P017
Difficulty: Level 3 of 5
Tag: Recursion
Grade: Grade 8, Grade 9
#10.18
#10.18

No Equal Neighbors

Strings Grade 8 Grade 9 ★★★☆☆

How many strings of length \(8\) over letters \(A,B,C\) have no two equal adjacent letters?

Details
Problem: COM-B1-M10-P018
Difficulty: Level 3 of 5
Tag: Strings
Grade: Grade 8, Grade 9
#10.19
#10.19

Steps \(1\) and \(3\)

Recursion Grade 8 Grade 9 ★★★☆☆

In how many ways can one climb \(12\) stairs if each move is \(1\) or \(3\) stairs?

Details
Problem: COM-B1-M10-P019
Difficulty: Level 3 of 5
Tag: Recursion
Grade: Grade 8, Grade 9
#10.20
#10.20

Tiles of Length \(1\), \(2\), \(3\)

Tiling Grade 8 Grade 9 ★★★☆☆

In how many ways can a \(1\times8\) strip be tiled by tiles of length \(1\), \(2\), and \(3\)?

Details
Problem: COM-B1-M10-P020
Difficulty: Level 3 of 5
Tag: Tiling
Grade: Grade 8, Grade 9
#10.21
#10.21

Squares and Dominoes

Tiling Grade 8 Grade 9 ★★★★☆

A \(2\times6\) board is tiled by vertical dominoes, pairs of horizontal dominoes, and \(2\times2\) squares. How many tilings are possible?

Details
Problem: COM-B1-M10-P021
Difficulty: Level 4 of 5
Tag: Tiling
Grade: Grade 8, Grade 9
#10.22
#10.22

Formula for Strings

Proof Grade 8 Grade 9 ★★★★☆

Prove that the number of binary strings of length \(n\) with no two adjacent ones is \(F_{n+2}\), where \(F_1=1\), \(F_2=1\).

Details
Problem: COM-B1-M10-P022
Difficulty: Level 4 of 5
Tag: Proof
Grade: Grade 8, Grade 9
#10.23
#10.23

Not Above the Diagonal

Grid paths Grade 8 Grade 9 ★★★★☆

How many paths from \((0,0)\) to \((4,4)\), using right and up moves, never go above the diagonal \(y=x\)?

Details
Problem: COM-B1-M10-P023
Difficulty: Level 4 of 5
Tag: Grid paths
Grade: Grade 8, Grade 9
#10.24
#10.24

Dominoes and L-Trominoes

Tiling Grade 8 Grade 9 ★★★★★

A \(2\times6\) board is tiled by dominoes and L-trominoes. Find the number of tilings.

Details
Problem: COM-B1-M10-P024
Difficulty: Level 5 of 5
Tag: Tiling
Grade: Grade 8, Grade 9

Ladders

No published ladders were found.
Previous Chapter
Next Chapter