learn › Counting & Discrete Math

Recurrences

lesson · about 3 minutes

Sequences defined step by step, and their shortcuts.

Pen and paper is fine · no calculator needed why?

Opens at level 42. You're level 1. You can read and practice here now.

the idea

A recurrence builds a sequence one term at a time from the terms before it. aₙ = 3aₙ₋₁ − 1 says: to get the next term, triple the last one and take away 1. Fibonacci adds the two terms before.

Stepping through works for a few terms, if you keep careful count of which term you are on. For terms far out, spot the pattern and use a closed form, a formula that gives the nth term directly. The Tower of Hanoi doubles its moves and adds one for each extra disk, which gives 2ⁿ − 1.

techniques

Step and label

A term a few steps out, including Fibonacci.

  1. Write each term with its label: a₁, a₂, a₃, and so on.
  2. Apply the rule to the last term, or the last two for Fibonacci, to get the next.
  3. Stop at the label the question asks for.
worked example

Example: a₁ = 3 and aₙ = 2aₙ₋₁ + 1. What is a₅?

  1. a₂ = 2 × 3 + 1 = 7.
  2. a₃ = 15, a₄ = 31, a₅ = 63.

Answer: 63

Double and add one

The fewest moves for the Tower of Hanoi.

  1. To move n disks: move n − 1 aside, move the biggest, then move the n − 1 back on top.
  2. So each extra disk doubles the moves and adds one: 1, 3, 7, 15.
  3. That is one less than a power of 2: 2ⁿ − 1.
worked example

Example: What is the minimum number of moves to solve the Tower of Hanoi with 8 disks?

  1. 2 to the power 8 is 256.
  2. 256 − 1 = 255.

Answer: 255

Spot the closed form

A term far out, where stepping would take too long.

  1. Write the first four or five terms.
  2. Compare them with powers of 2, squares, or a start times powers of 3.
  3. Check it against the start and the rule: it must give the terms the rule gives. Then use it.
worked example

Example: a₀ = 0 and aₙ = aₙ₋₁ + 2n − 1. What is a₁₂?

  1. Terms: 0, 1, 4, 9, 16, the squares.
  2. So aₙ = n², and a₁₂ = 12 × 12 = 144.

Answer: 144

watch out for

practice

Sign in to try one

Fibonacci

worked example

F₁ = F₂ = 1, and each term is the sum of the two before it. What is F₉?

Answer: 34

  1. Keep adding the last two terms: 1, 1, 2, 3, 5, 8, 13, 21, 34.
  2. So F₉ = 34.

Step through a rule

worked example

a₁ = 2 and aₙ = 3aₙ₋₁ − 1. What is a₅?

Answer: 122

  1. Apply the rule one step at a time: a₂ = 3 × 2 − 1 = 5.
  2. Then a₃ = 14, a₄ = 41, a₅ = 122.

Tower of Hanoi

worked example

What is the minimum number of moves to solve the Tower of Hanoi with 8 disks?

Answer: 255

  1. Moving n disks means moving n − 1 disks aside, the big one once, then the n − 1 back on top: the count doubles and adds one each time, giving 2ⁿ − 1.
  2. 2⁸ − 1 = 256 − 1 = 255.

Spot the formula

worked example

a₀ = 0 and aₙ = aₙ₋₁ + 2n − 1. What is a₂₄?

Answer: 576

  1. The terms go 0, 1, 4, 9, 16, …: adding the odd numbers 1, 3, 5, 7, … gives the squares, so aₙ = n².
  2. a₂₄ = 24² = 576.

Sign in to start