Pigeonhole Principle

The pigeonhole principle says that if more than n objects are placed into n boxes, at least one box holds two or more objects. The generalized version says that N objects in k boxes force some box to hold at least ⌈N/k⌉ objects. It proves that a repeat must exist without saying where.

Before this lesson: Sum and Product Rules for Counting and Proof by Contradiction

The idea

Put 13 people in a room. There are only 12 months, so at least two of them must share a birth month. You cannot say which month or which two people, but you can be sure a repeat exists. That simple fact, applied cleverly, settles many counting and existence questions.

Four boxes in a row, labeled box 1 to box 4, holding five numbered balls. Boxes 1, 2 and 4 hold one ball each. Box 3 holds two balls, numbered 3 and 5, and is outlined in orange with the label
Five objects in four boxes: however you place them, some box must get at least two.

The name comes from pigeons and the small compartments, called pigeonholes, that they roost in. Mathematicians also call it the box principle or Dirichlet’s principle, after Peter Gustav Lejeune Dirichlet, who used it in number theory in the 1800s.

The pigeonhole principle and its generalized form

Pigeonhole principle. If N objects go into k boxes and N ≥ k + 1, then some box contains at least 2 objects.

Generalized pigeonhole principle. If N objects go into k boxes, then some box contains at least ⌈N/k⌉ objects. The ceiling ⌈x⌉ is the smallest integer greater than or equal to x, so ⌈2.1⌉ = 3 and ⌈3⌉ = 3.

N \text{ objects in } k \text{ boxes} \implies \text{some box has at least } \left\lceil \frac{N}{k} \right\rceil \text{ objects}

Proof. Suppose, for contradiction, that every box holds at most ⌈N/k⌉ − 1 objects. Since ⌈N/k⌉ is less than N/k + 1, each box holds fewer than N/k objects. Then the k boxes hold fewer than k · N/k = N objects in total, which contradicts having N objects.

Turned around, the generalized principle answers “how many do I need?” questions. To force at least r objects into one of k boxes, you need N = k(r − 1) + 1 objects, because k(r − 1) objects can still be spread with exactly r − 1 in each box.

N = k(r - 1) + 1 \text{ objects force at least } r \text{ in some box}

How to use the pigeonhole principle

  1. Decide what the objects (pigeons) are and what the boxes (holes) are. Every object must fit in exactly one box.
  2. Count the objects N and the boxes k.
  3. If N is greater than k, some box holds two objects. In general, some box holds at least ⌈N/k⌉.
  4. Translate “two objects in one box” back into the problem, such as two people with the same birth month.
  5. For “how many do you need?” questions, find the worst case, k(r − 1), and add 1.

The hard part is usually step 1. Good boxes are things like months, colors, remainders mod n or regions of a picture.

Pigeonhole principle examples

Example 1: Matching socks

A dark drawer holds many black, white and gray socks. How many socks must you take out to be sure of a matching pair?

k = 3

The boxes are the 3 colors.

3 \text{ socks can all differ}

Worst case: one black, one white and one gray.

N = 3 + 1 = 4

One more sock than boxes.

4 \gt 3

With 4 socks in 3 color boxes, some color appears twice.

Answer: 4 socks. Three is not enough, because the worst case gives three different colors.

Example 2: The generalized principle

A school has 100 students in a grade. What is the largest number of them who are certain to share a birth month?

N = 100,\ k = 12

The objects are students and the boxes are months.

\frac{100}{12} = 8.33\ldots

Divide the objects by the boxes.

\left\lceil \frac{100}{12} \right\rceil = 9

Round up to the next integer.

12 \cdot 8 = 96 \lt 100

Check: 8 per month holds only 96 students, so some month has 9.

Answer: at least 9 students share a birth month. It cannot be guaranteed that 10 do: 4 months with 9 students and 8 months with 8 students gives 36 + 64 = 100.

Example 3: Drawing cards

How many cards must you draw from a standard 52-card deck to be sure of getting at least 3 cards of the same suit?

k = 4,\ r = 3

The boxes are the 4 suits, and we want 3 in one box.

4 \cdot (3 - 1) = 8

Worst case: 2 cards of each suit, with no suit reaching 3.

N = 8 + 1 = 9

The next card makes some suit reach 3.

Answer: 9 cards. Check with the generalized principle: ⌈9/4⌉ = ⌈2.25⌉ = 3.

Example 4: Remainders

Show that among any 6 integers, two of them have a difference that is divisible by 5.

0, 1, 2, 3, 4

The boxes are the possible remainders when dividing by 5.

6 \gt 5

Six integers go into 5 remainder boxes.

a \equiv b \pmod{5}

So two of them, a and b, have the same remainder (see modular arithmetic).

a = 5q_1 + r,\ b = 5q_2 + r

Write both with the shared remainder r.

a - b = 5(q_1 - q_2)

Subtract: the r terms cancel.

Answer: a − b is a multiple of 5, as required. The same argument shows that among any n + 1 integers, two differ by a multiple of n.

Example 5: Points in a square (word problem)

Five sprinklers are placed anywhere in a square lawn that is 2 meters on each side. Show that two of them are at most √2 ≈ 1.41 meters apart.

4 \text{ squares of side } 1

Split the lawn into four 1 m by 1 m squares. These are the boxes.

5 \gt 4

Five sprinklers in 4 squares, so two share a small square.

d \le \sqrt{1^2 + 1^2}

Two points in a 1 by 1 square are at most one diagonal apart (see Pythagorean theorem).

\sqrt{1^2 + 1^2} = \sqrt{2} \approx 1.41

Simplify.

Answer: two sprinklers are at most √2 m apart. A point on the border between two small squares can be placed in either one; any fixed choice works.

Common mistakes

MistakeExample of the errorFix
Expecting the principle to name the box“13 people, so two were born in January”It only says some month is shared, not which one.
Getting the count off by one“3 socks guarantee a pair with 3 colors”The worst case uses one of each color, so you need k + 1 = 4.
Rounding down instead of up100 students in 12 months gives 8 in some monthUse the ceiling: ⌈100/12⌉ = 9.
Using k · r instead of k(r − 1) + 13 cards of one suit need 4 · 3 = 12 cardsThe worst case is 2 per suit, so 4 · 2 + 1 = 9 cards.
Boxes that miss some objectsPairing {1, 10}, {2, 9}, {3, 8}, {4, 7} for numbers 1 to 10Every object needs a box. Add {5, 6} so all 10 numbers are covered.
Applying it when N is not larger than k“12 people must share a birth month”12 people can have 12 different months. You need 13.

Related ideas

The pigeonhole principle is an existence argument: like a proof by contradiction, it shows something must happen without building it. It is often paired with counting rules from sum and product rules for counting to find the number of boxes. Remainder boxes connect it to the division algorithm, and the next lesson, Combinations with Repetition, counts the ways to put identical objects into boxes.

Practice problems

  1. How many people must be in a room to be sure that two share a birthday? Count February 29 as a possible birthday.
  2. A class has 30 students. What is the largest number certain to be born on the same day of the week?
  3. A drawer holds red, blue, green and yellow socks. How many must you take to be sure of a matching pair?
  4. For the drawer in Problem 3, how many socks guarantee 3 of the same color?
  5. Show that if you choose any 6 numbers from 1 to 10, two of them add up to 11.
  6. Show that among any 8 integers, two have a difference divisible by 7.
  7. How many integers must you choose to be sure that two have the same last digit?
  8. Show that among any 3 integers, two have an even sum.
  9. A city has 900,000 people, and nobody has more than 200,000 hairs on their head. Show that at least 5 people have exactly the same number of hairs.
  10. In a group of n people (n ≥ 2), friendship is mutual. Show that two people have the same number of friends in the group.
Show answers

1.

366

The boxes are the possible birthdays, including February 29.

366 + 1 = 367

One more person than boxes.

Answer: 367 people

2.

\left\lceil \frac{30}{7} \right\rceil

30 students in 7 weekday boxes.

30 = 7 \cdot 4 + 2

Divide: 4 per day holds only 28 students.

\left\lceil \frac{30}{7} \right\rceil = 5

Round 4.28… up.

Answer: 5 students

3.

k = 4

The boxes are the 4 colors.

4 + 1 = 5

Worst case one of each color, then one more.

Answer: 5 socks

4.

4 \cdot (3 - 1) = 8

Worst case: 2 socks of each color.

8 + 1 = 9

The next sock makes 3 of one color.

Answer: 9 socks

5.

\{1,10\}, \{2,9\}, \{3,8\}, \{4,7\}, \{5,6\}

Make 5 boxes, each a pair that adds to 11. Every number from 1 to 10 is in exactly one.

6 \gt 5

Six numbers in 5 boxes.

Answer: two chosen numbers are in the same pair, so they add to 11

6.

0, 1, \ldots, 6

The boxes are the 7 remainders mod 7.

8 \gt 7

Two of the 8 integers, a and b, share a remainder.

a - b = 7(q_1 - q_2)

Subtract a = 7q1 + r and b = 7q2 + r.

Answer: a − b is divisible by 7

7.

10

The boxes are the last digits 0 to 9.

10 + 1 = 11

One more integer than boxes.

Answer: 11 integers

8.

\text{even}, \text{odd}

The 2 boxes are the parities.

3 \gt 2

Two of the 3 integers have the same parity.

\text{even} + \text{even},\ \text{odd} + \text{odd}

Both kinds of same-parity sum are even.

Answer: those two integers have an even sum

9.

200{,}000 + 1 = 200{,}001

The boxes are the hair counts 0, 1, …, 200,000.

200{,}001 \cdot 4 = 800{,}004 \lt 900{,}000

Four people per box holds too few people.

\left\lceil \frac{900{,}000}{200{,}001} \right\rceil = 5

So some box holds at least 5.

Answer: at least 5 people have the same number of hairs

10.

0, 1, \ldots, n - 1

Each person has between 0 and n − 1 friends.

0 \text{ and } n - 1 \text{ cannot both occur}

Someone friends with everyone rules out someone with no friends.

n - 1 \text{ boxes}

So the friend counts use at most n − 1 values.

n \gt n - 1

n people in n − 1 boxes.

Answer: two people have the same number of friends

Pigeonhole principle FAQ

What is the pigeonhole principle?

If more objects than boxes are placed into the boxes, at least one box gets two or more objects. For example, 13 people must include two with the same birth month.

What is the generalized pigeonhole principle?

If N objects go into k boxes, some box holds at least ⌈N/k⌉ objects. With 100 students and 12 months, some month has at least ⌈100/12⌉ = 9 birthdays.

How do you choose the pigeons and the holes?

The pigeons are the things you want two of, and the holes are the categories they could share, such as colors, remainders or regions. Every pigeon must fit in exactly one hole, and there must be fewer holes than pigeons.

How many objects guarantee r in one box?

With k boxes you need k(r − 1) + 1 objects. The first k(r − 1) can be spread out with r − 1 in each box, and the next one forces some box to r.

Summary

  • More than k objects in k boxes put at least 2 objects in some box.
  • Generalized: N objects in k boxes put at least ⌈N/k⌉ objects in some box.
  • To force r in one box, you need k(r − 1) + 1 objects.
  • Choose the boxes so that every object fits in exactly one, often by color, remainder or region.
  • The principle proves that a repeat exists but does not say where it is.

Previous lesson: Sum and Product Rules for Counting

Next lesson: Combinations with Repetition

Back to the Discrete Math Index