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 mn−m−nmn-m-n is representable as am+bnam+bn (with a,b≥0a,b \ge 0), and mn−m−nmn-m-n itself is not. In other words the greatest non representable positive integer is

mn−m−n.mn - m - n.

For example, with m=6m=6 and n=7n=7, the largest non representable value is (6)(7)−6−7=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

(m−1)(n−1)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 mn−m−nmn-m-n is not representable.

Suppose am+bn=mn−m−nam+bn = mn-m-n with a,b≥0a,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+1≥mb+1\ge m, ie. b≥m−1b\ge m-1. Similarly a≥n−1a\ge n-1. Then am+bn≥(n−1)m+(m−1)n=2mn−m−n>mn−m−nam+bn \ge (n-1)m+(m-1)n = 2mn-m-n > mn-m-n, a contradiction.

Step 2: Show every integer greater than mn−m−nmn-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 0≤b≤m−10\le b\le m-1). Any integer in that residue class that is ≥bn\ge bn can be written as am+bnam+bn with a≥0a\ge 0. The largest threshold across all residue classes is (m−1)n(m-1)n, so the largest non representable value in any class is at most (m−1)n−m=mn−m−n(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)−m−n.\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)−5−8=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 (3−1)(7−1)2=6\frac{(3-1)(7-1)}{2}=6.

We can verify the nonrepresentable values are 1,2,4,5,8,111,2,4,5,8,11, which is 66 values, and the largest is 11=(3)(7)−3−711=(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 nonrepresentable value is

(13)(5)−13−5=47.(13)(5)-13-5=47.

Thus every integer greater than 4747 is representable, and 4747 itself is not.

Therefore the answer is 47\boxed{47}.

Example 4: Interesting Alien Problem!

An alien Flying Saucer can reenergize using only two types of energy cells:

  • The first type gives 8484 energy units,
  • The second type gives 126126 energy units.

Also, ANY number of EACH type may be used.

The UFO's system can only operate well if the total amount of energy is some positive multiple of 4242.

Your task is to find the largest multiple of 4242 that CANNOT be produced.

First of all, we have

m=84,n=126.m=84,\quad n=126.

Next, since

gcd⁡(84,126)=42,\gcd(84,126)=42,

we can use the generalized Chicken McNugget theorem here, as follows:

lcm(84,126)−84−126.\mathrm{lcm}(84,126)-84-126.

Now,

lcm(84,126)=84⋅12642=252.\mathrm{lcm}(84,126)=\frac{84\cdot126}{42}=252.

Therefore the largest multiple of 4242 that cannot be reached is simply

252−84−126=42.252-84-126=42.

Thus, the answer is 42\boxed{42}.

Example 5: A creepy infinite staircase

An alien stands at the bottom of an infinite staircase and can only move upward by either 1717 steps or 2929 steps at a single time.

A step is called skibidi if the robot can never ever land on it no matter what combination of steps he takes.

Your task is to find the sum of all skibidi steps.

To begin with, because

gcd⁡(17,29)=1,\gcd(17,29)=1,

we can use the formula for the SUM of all nonrepresentable integers (which can be derived fairly easily, and you should try it out as an exercise):

(m−1)(n−1)(2mn−m−n−1)12.\frac{(m-1)(n-1)(2mn-m-n-1)}{12}.

Substituting in m=17m=17 and n=29n=29 gives

(16)(28)(2(17)(29)−17−29−1)12.\frac{(16)(28)(2(17)(29)-17-29-1)}{12}.

Simplifying:

2(17)(29)−17−29−1=986−47=939.2(17)(29)-17-29-1=986-47=939.

Thus, we have that the sum is:

(16)(28)(939)12.\frac{(16)(28)(939)}{12}.

Since 16⋅2812=1123\frac{16\cdot28}{12}=\frac{112}{3}, we obtain

112⋅9393=112⋅313=35056.\frac{112\cdot939}{3}=112\cdot313=35056.

Thus, the answer is 35056\boxed{35056}.

Example 6: The Weird Coin Vault

A rather peculiar vault accepts deposits only in bundles of the following:

  • 1414,
  • 2525,
  • or 3939.

Your job is to find the greatest integer that CANNOT be expressed in the form

14a+25b+39c14a+25b+39c

for all nonnegative integers a,b,ca,b,c.

First, notice that

39=14+25.39=14+25.

Thus

=14(a+c)+25(b+c).$$ So every integer that can be reached simply takes the following form:

14x+25y

for nonnegative integers $x,y$. Since

\gcd(14,25)=1,

theChickenMcNuggettheoremapplies,givingthelargestintegerthatcan′tberepresentedasthe Chicken McNugget theorem applies, giving the largest integer that can't be represented as

(14)(25)-14-25=350-39=311.

Thus, the answer is $\boxed{311}$. ## Some More Insight For two coprime positive integers $m$ and $n$, the value $mn-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 $mn-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+bn$ and applying the formula directly. ### Fast Check Trick To check whether a specific number $N$ is representable as $am+bn$, work modulo the smaller value (say $m$). Solve $bn \equiv N \pmod{m}$ for the smallest nonnegative $b$. If $bn \le N$, then $N$ is representable (set $a = (N - bn)/m$). Otherwise it is not. This is often much faster than guessing pairs $(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$. If the gcd is greater than $1$, 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 $6$, $10$, $15$, since $\gcd(6,10)=2$, the pair $\{6,10\}$ covers all sufficiently large even numbers, while adding $15$ (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 $m$ and $n$ are not coprime. - Forgetting that $a$ and $b$ must be nonnegative (not just any integers). - Confusing the largest non representable value ($mn-m-n$) with the count of non representable values ($\frac{(m-1)(n-1)}{2}$). ## Practice Problems <Problems problems="practice" />

Module Progress:

Join the Discord Community!

Stuck on a problem, or don't understand a module? Join the Discord and get help with your doubts while making more math friends.

PrevNext