PrevNext

Overview

Many competition problems ask, 'given two fixed positive integers, what is the largest integer that cannot be formed using nonnegative multiples of them?' The Chicken McNugget Theorem answers this question completely when the two integers are coprime.

This result is also known as the Frobenius Coin Problem or the Postage Stamp Problem.

Motivation

Suppose a shop sells chicken nuggets only in boxes of 66 and 99. Which totals can you buy?

Since gcd(6,9)=3\gcd(6,9)=3, you can only ever purchase multiples of 33, so many totals (like 11, 22, 44, \ldots) are impossible.

Now suppose the box sizes are 66 and 77. Because gcd(6,7)=1\gcd(6,7)=1, it turns out that every sufficiently large integer can be represented as 6a+7b6a+7b for nonnegative integers a,ba,b. In fact, once you pass a certain threshold, every number works with no gaps. The natural question is what is the largest integer that cannot be represented?

Theorem Statement

Chicken McNugget Theorem. Let mm and nn be positive integers with gcd(m,n)=1\gcd(m,n)=1. Then every integer greater than mnmnmn-m-n is representable as am+bnam+bn (with a,b0a,b \ge 0), and mnmnmn-m-n itself is not. In other words the greatest non representable positive integer is

mnmn.mn - m - n.

For example, with m=6m=6 and n=7n=7, the largest non representable value is (6)(7)67=29(6)(7) - 6 - 7 = 29.

Counting Non Representable Values

Under the same hypotheses, the number of positive integers that cannot be represented as am+bnam+bn is exactly

(m1)(n1)2.\frac{(m-1)(n-1)}{2}.

With m=6,n=7m=6,\,n=7 there are (5)(6)2=15\frac{(5)(6)}{2}=15 non representable values.

Proof Outline

We can outline the main ideas behind a proof.

Setup. Call a nonnegative integer NN representable if N=am+bnN=am+bn for some nonnegative integers a,ba,b.

Step 1: Show mnmnmn-m-n is not representable.

Suppose am+bn=mnmnam+bn = mn-m-n with a,b0a,b\ge 0. Rearranging gives (a+1)m+(b+1)n=mn(a+1)m + (b+1)n = mn. Since gcd(m,n)=1\gcd(m,n)=1 and m(b+1)nm\mid(b+1)n, we need m(b+1)m\mid(b+1), so b+1mb+1\ge m, ie. bm1b\ge m-1. Similarly an1a\ge n-1. Then am+bn(n1)m+(m1)n=2mnmn>mnmnam+bn \ge (n-1)m+(m-1)n = 2mn-m-n > mn-m-n, a contradiction.

Step 2: Show every integer greater than mnmnmn-m-n is representable.

The key idea is that once we can hit every residue class modulo mm using multiples of nn, adding copies of mm lets us reach all sufficiently large numbers.

For each residue class modulo mm, there is a smallest nonnegative number of the form bnbn in that class (where 0bm10\le b\le m-1). Any integer in that residue class that is bn\ge bn can be written as am+bnam+bn with a0a\ge 0. The largest threshold across all residue classes is (m1)n(m-1)n, so the largest non representable value in any class is at most (m1)nm=mnmn(m-1)n - m = mn - m - n.

Combining both steps completes the proof.

When gcd(m,n)>1\gcd(m,n)>1

If mm and nn are not coprime, set d=gcd(m,n)d=\gcd(m,n). Then am+bnam+bn is always a multiple of dd, so infinitely many positive integers are non representable and no finite 'largest' exists in the usual sense.

However among the multiples of dd, the largest non representable one is

lcm(m,n)mn.\text{lcm}(m,n) - m - n.

This follows by applying the coprime theorem to m/dm/d and n/dn/d, then scaling back by dd.

Worked Examples

Example 1

What is the greatest positive integer that cannot be written as 5a+8b5a+8b for nonnegative integers a,ba,b?

Since gcd(5,8)=1\gcd(5,8)=1, the answer is (5)(8)58=27(5)(8)-5-8= 27.

Example 2

How many positive integers cannot be expressed as 3a+7b3a+7b for nonnegative integers a,ba,b?

Since gcd(3,7)=1\gcd(3,7)=1, the count is (31)(71)2=6\frac{(3-1)(7-1)}{2}=6.

We can verify, the non representable values are 1,2,4,5,8,111,2,4,5,8,11, which is 66 values, and the largest is 11=(3)(7)3711=(3)(7)-3-7.

Example 3 (AMC 10B 2015 Problem 15)

The town of Hamlet has 33 people for each horse, 44 sheep for each cow, and 33 ducks for each person. Which of the following could not possibly be the total number of people, horses, sheep, cows, and ducks in Hamlet?

(A) 41(B) 47(C) 59(D) 61(E) 66\textbf{(A)}\ 41\quad\textbf{(B)}\ 47\quad\textbf{(C)}\ 59\quad\textbf{(D)}\ 61\quad\textbf{(E)}\ 66

Let hh be the number of horses and cc the number of cows. Then the town has 3h3h people, hh horses, 3(3h)=9h3(3h)=9h ducks, cc cows, and 4c4c sheep, for a total of 13h+5c13h+5c.

Since gcd(13,5)=1\gcd(13,5)=1, the largest non representable value is (13)(5)135=47(13)(5)-13-5=47. Therefore (B)\textbf{(B)}.

Some More Insight

For two coprime positive integers mm and nn, the value mnmnmn-m-n acts as a threshold. Everything above it is representable, while values at or below it may or may not be. In contest problems this means

  • If a target value exceeds mnmnmn-m-n, it is automatically representable, no further checking is needed.
  • You only need to examine values up to the bound to determine which ones fail.
  • Many problems reduce to recognising the form am+bnam+bn and applying the formula directly.

Fast Check Trick

To check whether a specific number NN is representable as am+bnam+bn, work modulo the smaller value (say mm). Solve bnN(modm)bn \equiv N \pmod{m} for the smallest nonnegative bb. If bnNbn \le N, then NN is representable (set a=(Nbn)/ma = (N - bn)/m). Otherwise it is not.

This is often much faster than guessing pairs (a,b)(a,b) directly, and it comes up frequently.

Strategy Tips

  • Check coprimality first. The theorem only gives a finite answer when gcd(m,n)=1\gcd(m,n)=1. If the gcd is greater than 11, reduce or use the lcm form.
  • Three or more denominations. There is no closed form Frobenius number for three or more values, but you can often reduce the problem. For instance, with denominations 66, 1010, 1515, since gcd(6,10)=2\gcd(6,10)=2, the pair {6,10}\{6,10\} covers all sufficiently large even numbers, while adding 1515 (odd) lets you reach odd numbers too. Casework or systematic checking is usually needed.
  • Parity and residues. Thinking in terms of residue classes modulo the smaller value is a great way to organise which totals are achievable.

Common Pitfalls

  • Applying the formula when mm and nn are not coprime.
  • Forgetting that aa and bb must be nonnegative (not just any integers).
  • Confusing the largest non representable value (mnmnmn-m-n) with the count of non representable values ((m1)(n1)2\frac{(m-1)(n-1)}{2}).

Practice Problems

StatusSourceProblem NameDifficultyTags
AMC 10BHard
Show TagsChicken Mcnugget
AIME IIHard
Show TagsChicken Mcnugget
AIMEHard
Show TagsChicken Mcnugget

Module Progress:

Join the AoPS Community!

Stuck on a problem, or don't understand a module? Join the AoPS community and get help from other math contest students.

PrevNext