Module 2.7 · Counting and Probability
Recursion and states
Some counting and probability problems have no clean formula you can write down directly, but they have a clean relationship between a problem and smaller copies of itself. Recursion counts things by building them one step at a time. Its probability twin, the states method, tracks "where you are" in a random process and writes an equation for each state. Both are late-AMC staples.
Counting with recursion
Suppose you want the number of ways to climb a staircase of steps taking or steps at a time. Call it . Look at the first move:
- If it's a -step, the rest is a climb of steps: ways.
- If it's a -step, the rest is a climb of steps: ways.
So , with and . These are the Fibonacci numbers:
Building a recursion
- Define = the number of valid objects of size .
- Split by what happens first (or last): the first tile, the first letter, the first move.
- Each case leaves a smaller valid object. Write in terms of earlier terms.
- Compute a few starting values by hand, then iterate. On the AMC, iterating up to or by hand is normal.
When a restriction depends on what came just before (like "no two consecutive s"), split by how the object starts until the restriction is resolved. A string with no two consecutive s either starts with (then anything valid of length follows) or starts with (then anything valid of length ). Again .
Probability with states
In a random process, a state is all the information about the present that matters for the future. Let be the probability of winning from state . Condition on the next step:
This gives one linear equation per state. Solve the system. The same idea works for expected values, with an extra "" for the step you just took.
Worked example: Tiling a strip
In how many ways can a strip be tiled with squares and dominoes?
Let be the number of tilings of a strip. The leftmost tile is a square (leaving ) or a domino (leaving ), so with , :
So .
Worked example: Stairs with three step sizes
How many ways can you climb stairs taking , or steps at a time?
Now , with (one way to climb nothing), , :
The answer is .
Worked example: A dice race
Alex and Blair take turns rolling a fair die, Alex first. The first person to roll a wins. What is the probability that Alex wins?
Let be the probability that the player about to roll eventually wins. Alex wins right away with probability . Otherwise (), Blair becomes the player about to roll, and Alex wins only if Blair doesn't: probability . So
Common mistake
Check your starting values carefully. Most recursion errors are off-by-one mistakes in , or . Always verify the recursion on a case small enough to list by hand, such as or .
Worked example: A frog on a triangle
A frog sits on vertex of a triangle . Each second it jumps to one of the other two vertices, each with probability . What is the probability that it is back at after jumps?
Let be the probability it's at after jumps. To be at after jumps, it must be not at after jumps, then jump to (probability ). So
Then , , , .
Practice
In how many ways can you climb a staircase of steps if each move goes up or steps?
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
Ana and Ben take turns flipping a fair coin, Ana first. The first person to flip heads wins. What is the probability that Ana wins?
How many subsets of , including the empty set, contain no two consecutive integers?
How many strings of length made of the letters A and B contain no three consecutive A's?
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
A bug starts at vertex of triangle . Each minute it crawls to one of the other two vertices, each with probability . What is the probability that the bug is at after minutes?
How many strings of length using the digits , and contain no two consecutive s?
In how many ways can a rectangle be tiled with dominoes?
A gambler starts with chips. Each round, she wins a chip with probability or loses a chip with probability . She stops when she has chips or chips. What is the probability that she ends with chips?
Real contest practice
- 2020 AMC 10A, Problem 13: a frog's random walk in a square, solved with states and symmetry.
- 2015 AMC 10A, Problem 22: people around a table, no two neighbors standing; a recursion on seating patterns.
- 2019 AMC 10B, Problem 25: binary sequences with restrictions on consecutive digits.