Discrete Mathematics and Combinatorics

The Pigeonhole Principle and Its Surprising Consequences

A rule a child can grasp proves facts about birthdays, divisibility, points in a square, file compression and unavoidable order.

Key takeaways

  • If n + 1 or more objects go into n boxes, at least one box holds two or more.
  • In the general form, N objects in k boxes force some box to hold at least N/k, rounded up.
  • The skill lies in deciding what the objects are and what the boxes are.
  • The principle proves existence without identifying the example, and it can show that some tasks are impossible.

The pigeonhole principle says that if you put more objects into boxes than there are boxes, some box must receive at least two. With 10 pigeons and 9 holes, at least one hole is shared. That is the whole idea.

Its power comes from choosing the objects and the boxes cleverly. The principle then proves that something must exist, even when you have no way of saying which one it is.

The basic and general forms

The proof is by contradiction. If every one of n boxes held at most 1 object, there would be at most n objects in total. With more than n, that cannot be.

The same argument gives a stronger version. If N objects go into k boxes, some box holds at least ⌈N/k⌉ of them. The symbol ⌈x⌉, called the ceiling of x, means x rounded up to a whole number.

With 100 people and 12 birth months, some month contains at least ⌈100/12⌉ = 9 birthdays. If every month had 8 or fewer, you could account for only 96 people.

Notice the word "some". The principle does not say which month, and it does not say that every month is crowded.

Socks, months and hairs

A drawer holds loose socks in 3 colors. How many must you take in the dark to be sure of a matching pair? Four. The colors are the boxes, and three socks might all differ.

How many to be sure of 5 socks of one color, assuming there are plenty of each? You could draw 4 of each color, 12 socks, and still fail. The 13th settles it.

guarantee m objects in one of k boxes:  k(m − 1) + 1 objects
m = 5, k = 3:                            3 × 4 + 1 = 13

A classic application concerns hair. A human head carries far fewer than a million hairs. In a city of several million people, then, at least two have exactly the same number of hairs. In fact several do, though nobody could easily find them.

Do not confuse this with the birthday problem. You need 367 people to be certain of a shared birthday, counting February 29, but only 23 for the chance to pass one half under the usual uniform model of 365 days.

Choosing clever boxes: divisibility

Pick any 51 different whole numbers from 1 to 100. Then one of your numbers divides another. This sounds hard until you find the boxes.

Write each chosen number as a power of 2 times an odd number, so that 40 = 8 × 5 and 17 = 1 × 17. The odd part is one of 1, 3, 5, ..., 99, which gives only 50 boxes. With 51 numbers, two share an odd part. They differ only in their power of 2, so the smaller divides the larger.

The bound is sharp. The 50 numbers from 51 to 100 contain no such pair, since twice any of them already exceeds 100.

From the same 51 numbers you can also find two with no common factor above 1. Use the boxes {1, 2}, {3, 4}, ..., {99, 100}. Two chosen numbers fall in one box, so they are consecutive, and consecutive numbers share no such factor.

How to build a pigeonhole argument
1 State the goal Two things that must share a property 2 Design the boxes Sharing a box should give that property 3 Count both Show objects outnumber boxes 4 Draw the conclusion Some box holds two, so the goal holds State the goal Two things that must share a property 1 Design the boxes Sharing a box should give that property 2 Count both Show objects outnumber boxes 3 Draw the conclusion Some box holds two, so the goal holds 4

Remainders and running totals

Take any n whole numbers, a₁ to aₙ, repeats allowed. Some unbroken run of them has a sum divisible by n.

Form the running totals a₁, a₁ + a₂, and so on, up to the sum of all n. If any total is divisible by n, you are done. If none is, the n totals have remainders among 1, 2, ..., n − 1. That is n objects in n − 1 boxes, so two totals share a remainder. Their difference is divisible by n, and it is exactly the sum of the run between them.

numbers:  3, 7, 2, 6, 4          n = 5
totals:   3, 10, 12, 18, 22
10 is divisible by 5:  3 + 7 = 10
also 12 and 22 share remainder 2:  22 − 12 = 6 + 4 = 10

Points in a square

Place 5 points anywhere in a square of side 1. Two of them are at distance at most √2/2, about 0.707.

Cut the square into 4 smaller squares of side 1/2. Five points in 4 pieces means some piece holds two. The farthest apart two points in such a piece can be is its diagonal, √2/2.

The same method works for triangles, cubes and circles. Divide the region into pieces of small diameter, then put in one more point than there are pieces.

Good approximations to irrational numbers

In the nineteenth century Peter Gustav Lejeune Dirichlet used the principle to show that every real number can be well approximated by fractions. It is often called Dirichlet's drawer principle for that reason.

Take an irrational number α and a positive integer N. Look at the fractional parts of 0, α, 2α, ..., Nα. These are N + 1 numbers between 0 and 1. Split that interval into N equal boxes. Two of them, from iα and jα with i < j, land together, so with q = j − i the number qα is within 1/N of some integer p.

Dividing by q gives |α − p/q| < 1/(Nq), where q ≤ N. For π, the fraction 22/7 is a familiar example of an unusually close fit for its size. Continued fractions find such fractions efficiently.

What cannot be done

No lossless compression method can shorten every file. "Lossless" means the original can be recovered exactly, so different inputs must give different outputs.

There are 2ⁿ bit strings of length n. All shorter strings, including the empty one, number 1 + 2 + 4 + ... + 2ⁿ⁻¹ = 2ⁿ − 1. That is one box too few. So at least one file of length n does not get shorter. Real compressors succeed because the files people care about have patterns, and they pay for it on files without them. This idea leads to shortest descriptions.

Hash functions face the same fact. If a function turns arbitrarily long inputs into outputs of fixed length, different inputs must sometimes collide.

Order you cannot avoid

Among any group of at least 2 people, if friendship is mutual and nobody is counted as their own friend, two people have the same number of friends within the group. In a group of n, the possible numbers run from 0 to n − 1. But 0 and n − 1 cannot both occur, since someone friendless rules out someone friends with all. That leaves n − 1 usable boxes for n people.

Another result, due to Paul Erdős and George Szekeres, says that any list of (r − 1)(s − 1) + 1 different numbers contains an increasing subsequence of length r or a decreasing one of length s. A list of 10 different numbers therefore always has 4 in increasing order or 4 in decreasing order, not necessarily next to each other.

These are the first steps into Ramsey theory. For instance, among any 6 people, 3 all know each other or 3 are all mutual strangers, and the proof starts by pigeonholing one person's 5 relationships into 2 types.

Why decimals repeat

Divide 1 by 7 using long division. At each step you carry a remainder, and the only possible remainders are 0 through 6. If the remainder 0 appears, the decimal stops. Otherwise every remainder is one of 6 values, so within 7 steps some remainder must come back.

From that moment the digits cycle, because each step depends only on the current remainder. Here 1/7 = 0.142857142857..., a block of 6 digits. The same reasoning shows that every fraction p/q of whole numbers has a decimal that terminates or eventually repeats, with a repeating block of at most q − 1 digits.

It follows that a decimal which never settles into a repeating block, such as 0.101001000100001..., cannot be a fraction.

An averaging version

If the average of several numbers is A, then at least one of them is A or more, and at least one is A or less. This is the pigeonhole idea applied to quantities.

Arrange the numbers 1 to 10 around a circle in any order. Some three neighbors add to at least 17. There are 10 blocks of three neighbors, and each number belongs to exactly 3 of them.

total of all block sums   3 × 55 = 165
average block sum         165 / 10 = 16.5
block sums are whole, so some block is at least 17

The same averaging step shows that some block is at most 16.

Problems to try

  1. Show that among any 5 whole numbers, two differ by a multiple of 4. The boxes are the 4 possible remainders.
  2. Take 5 points with integer coordinates in the plane. Show that the midpoint of some pair also has integer coordinates. Sort the points by whether each coordinate is odd or even, which gives 4 classes.
  3. Choose 51 numbers from 1 to 100. Show that two of them add to 101. Use the 50 pairs {1, 100}, {2, 99} and so on up to {50, 51}.

In each case, try to find the largest selection that avoids the conclusion. Four numbers with different remainders show that 5 is the smallest number that works in the first problem.

Common misconceptions

  • The principle gives no probability. It speaks only of certainty.
  • It does not require objects to be spread evenly. One box may hold everything while others are empty.
  • It needs strictly more objects than boxes. With 9 pigeons and 9 holes, each can have its own.
  • Infinitely many objects in finitely many boxes force some box to hold infinitely many, but not every box.

When you get stuck on an existence problem, ask what would make two things "close enough", and make that your box.

Written for 4Mathematics with AI writing tools and not reviewed line by line by a person. Check anything you rely on against a textbook or primary source. Report an error.

Keep reading

All 45 articles in Discrete Mathematics and Combinatorics →

Latest news on this topic