On this page
Write down any five whole numbers. However you choose them, three of them will add up to a multiple of 3. Swap 3 for any n and five for 2n−1, and you have the Erdős–Ginzburg–Ziv theorem, a classic result in combinatorial number theory.
What does the Erdős–Ginzburg–Ziv theorem say?
The Erdős–Ginzburg–Ziv theorem states that every sequence of 2n−1 integers contains n terms whose sum is divisible by n (MathWorld). Paul Erdős, A. Ginzburg and A. Ziv published it in 1961 as "Theorem in the additive number theory" in the Bulletin of the Research Council of Israel, volume 10F, pages 41–43 (Wikipedia, Zero-sum problem).
It is called a zero-sum result because you can replace each integer by its remainder mod n. The theorem then says that any 2n−1 elements of the integers mod n contain n elements that add up to 0. The open-source Lean library Mathlib has a machine-checked proof, and its documentation describes it as "a corollary of Chevalley-Warning" (Mathlib documentation).
Why is 2n−2 integers not enough?
Take n−1 copies of 0 and n−1 copies of 1. That is 2n−2 integers, and no n of them have a sum divisible by n (MathWorld). The reason is short:
Any n of them include at least one 1, since there are only n−1 zeros.
They include at most n−1 ones.
So the sum is between 1 and n−1, never a multiple of n.
For n = 3 the bad list is 0, 0, 1, 1. Any three of them add up to 1 or 2. Add a fifth number of any value and, by the theorem, a good triple appears. So 2n−1 is the exact threshold, not just a convenient bound.
How do you find the three numbers when n = 3?
The case n = 3 has a proof you can do on paper. Take 4, 7, 9, 11 and 13.
Write each remainder mod 3: 4 → 1, 7 → 1, 9 → 0, 11 → 2, 13 → 1.
Look for a remainder that appears three times. Three equal remainders r add to 3r, which is a multiple of 3. Here 4, 7 and 13 all leave remainder 1, and 4 + 7 + 13 = 24 = 3 × 8.
If no remainder appears three times, each appears at most twice. Five numbers in three remainder classes, at most two per class, must fill all three classes. Then pick one number from each class: 0 + 1 + 2 = 3. In our list, 9 + 4 + 11 = 24 works too.
One of the two cases always happens, so five integers are always enough. Try it on 2, 5, 8, 10, 14 before reading on. The remainders are 2, 2, 2, 1, 2, so step 2 applies: 2 + 5 + 8 = 15.
How does the Chevalley–Warning theorem prove it for primes?
The Chevalley–Warning theorem (Chevalley and Warning, both 1935) says this about polynomials over a finite field whose characteristic is p. If the number of variables is greater than the sum of the polynomials' total degrees, then the number of common zeros is divisible by p (Wikipedia, Chevalley–Warning theorem). Lecture notes by Matt DeVos of Simon Fraser University give this proof of the prime case (DeVos, Subsequence Sums II):
Take 2p−1 numbers a₁, …, a₂ₚ₋₁ modulo p and variables x₁, …, x₂ₚ₋₁.
Form two polynomials: the sum of xᵢ^(p−1), and the sum of aᵢ·xᵢ^(p−1). Each has degree p−1, so the total is 2p−2, which is less than the 2p−1 variables.
All zeros is a common zero, so the count of common zeros is a positive multiple of p. That means there is another one, z.
By Fermat's little theorem, xᵖ⁻¹ is 1 mod p when x is non-zero and 0 when x is 0. So at z the first polynomial equals the number of non-zero entries, taken mod p. Since it is 0, that number is a multiple of p between 1 and 2p−1, so it is exactly p.
The second polynomial then says the aᵢ at those p positions sum to 0 mod p.
For p = 3 that means five variables against a total degree of 4. Fermat's little theorem itself follows from Lagrange's theorem on cosets and group order.
How do you get from primes to every n?
The same notes show that the theorem passes from smaller cases to products. They also note that this reduction to primes, together with the prime case, is the structure of the original argument (DeVos). For n = 6 = 2 × 3, take 11 integers. Pull out three with sum divisible by 3, and repeat while five or more remain. 11 becomes 8, then 5, then 2, giving three disjoint triples with sums 3b₁, 3b₂, 3b₃. Now use the n = 2 case on b₁, b₂, b₃: two of them have an even sum. Those two triples are six integers with a sum divisible by 6.
If the step from xᵖ⁻¹ to counting feels slippery, look up modular arithmetic and Fermat's little theorem in the Fermi Concept Library, which covers every concept in physics, chemistry, biology, mathematics and computing. For worked problems, the Fermi Problem Library has a step-by-step solver that explains the reasoning rather than printing an answer.
For more counting arguments in the same spirit, read why six people always contain three friends or three strangers and the Erdős–Ko–Rado theorem on intersecting families.



