Difference between revisions of "Chicken McNugget Theorem"

m
(Intermediate)
(75 intermediate revisions by 34 users not shown)
Line 1: Line 1:
 
The '''Chicken McNugget Theorem''' (or '''Postage Stamp Problem''' or '''Frobenius Coin Problem''') states that for any two [[relatively prime]] [[positive integer]]s <math>m,n</math>, the greatest integer that cannot be written in the form <math>am + bn</math> for [[nonnegative]] integers <math>a, b</math> is <math>mn-m-n</math>.
 
The '''Chicken McNugget Theorem''' (or '''Postage Stamp Problem''' or '''Frobenius Coin Problem''') states that for any two [[relatively prime]] [[positive integer]]s <math>m,n</math>, the greatest integer that cannot be written in the form <math>am + bn</math> for [[nonnegative]] integers <math>a, b</math> is <math>mn-m-n</math>.
  
A consequence of the theorem is that there are exactly <math>\frac{(m - 1)(n - 1)}{2}</math> positive integers which cannot be expressed in the form <math>am + bn</math>. The proof is based on the fact that in each pair of the form <math>(k, (m - 1)(n - 1) - k+1)</math>, exactly one element is expressible.
+
A consequence of the theorem is that there are exactly <math>\frac{(m - 1)(n - 1)}{2}</math> positive integers which cannot be expressed in the form <math>am + bn</math>. The proof is based on the fact that in each pair of the form <math>(k, mn-m-n-k)</math>, exactly one element is expressible.
  
 
== Origins ==
 
== Origins ==
The story goes that the Chicken McNugget Theorem got its name because in McDonalds, people bought Chicken McNuggets in 9 and 20 piece packages. Somebody wondered what the largest amount you could never buy was, assuming that you did not eat or take away any McNuggets.  They found the answer to be 151 McNuggets, thus creating the Chicken McNugget Theorem.
+
There are many stories surrounding the origin of the Chicken McNugget theorem. However, the most popular by far remains that of the Chicken McNugget. Originally, McDonald's sold its nuggets in packs of 9 and 20. Math enthusiasts were curious to find the largest number of nuggets that could not have been bought with these packs, thus creating the Chicken McNugget Theorem (the answer worked out to be 151 nuggets). The Chicken McNugget Theorem has also been called the Frobenius Coin Problem or the Frobenius Problem, after German mathematician Ferdinand Frobenius inquired about the largest amount of currency that could not have been made with certain types of coins.
 +
 
 +
==Proof Without Words==
 +
<math>\begin{array}{ccccccc}
 +
0\mod{m}&1\mod{m}&2\mod{m}&...&...&...&(m-1)\mod{m}\\
 +
\hline
 +
\cancel{0n}&1&2&&...&&m-1\\
 +
\cancel{0n+m}&...&&\vdots&&...&\\
 +
\cancel{0n+2m}&...&&\cancel{1n}&&...&\\
 +
\cancel{0n+3m}&&&\cancel{1n+m}&&\vdots&\\
 +
\cancel{0n+4m}&&&\cancel{1n+2m}&&\cancel{2n}&\\
 +
\cancel{0n+5m}&&&\cancel{1n+3m}&&\cancel{2n+m}&\\
 +
\vdots&&&\vdots&&\vdots&\\
 +
\cancel{\qquad}&\cancel{\qquad}&\cancel{ \qquad}&\cancel{ \qquad}&\mathbf{(m-1)n-m}&\cancel{\qquad }&\cancel{\qquad }\\
 +
\cancel{\qquad}&\cancel{\qquad}&\cancel{ \qquad}&\cancel{ \qquad}&\cancel{(m-1)n}&\cancel{\qquad }&\cancel{\qquad }
 +
\end{array}</math>
 +
 
 +
 
 +
Example using  m=<math>\color{magenta}11</math> and n=<math>\color{blue}4</math>
 +
 
 +
<math>
 +
\begin{array}{ccccccccccc}
 +
0 & 1 & 2 & 3 & \color{blue}\cancel{4}& 5 & 6 & 7 & \color{blue}\cancel{8} & 9 & 10 \\
 +
\color{magenta}\cancel{11} & \color{blue}\cancel{12} & 13 & 14 & \cancel{15} & \color{blue}\cancel{16} & 17 & 18 & \cancel{19} & \color{blue}\cancel{20} & 21 \\
 +
\cancel{22} & \cancel{23} & \color{blue}\cancel{24} & 25 & \cancel{26} & \cancel{27} & \color{blue}\cancel{28} & \color{red}\bold 29 & \cancel{30} & \cancel{31} & \color{blue}\cancel{32} \\
 +
\cancel{33} & \cancel{34} & \cancel{35} & \color{blue}\cancel{36} & \cancel{37} & \cancel{38} & \cancel{39} & \color{blue}\cancel{40} & \cancel{41} & \cancel{42} & \cancel{43} \\
 +
\cancel{44} & \cancel{ 45 } & \cancel{ 46 } & \cancel{ 47 } & \cancel{ 48 } & \cancel{ 49 } & \cancel{ 50 } & \cancel{ 51 } & \cancel{ 52 } & \cancel{ 53 } & \cancel{ 54 }\\
 +
\cancel{55} & \cancel{ 56 } & \cancel{ 57 } & \cancel{ 58 } & \cancel{ 59 } & \cancel{ 60 } & \cancel{ 61 } & \cancel{ 62 } & \cancel{ 63 } & \cancel{ 64 } & \cancel{ 65 } \\ 
 +
\vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots  \\\
 +
\cancel{\qquad} & \cancel{\qquad} & \cancel{\qquad} & \cancel{\qquad} & \cancel{\qquad} & \cancel{\qquad} & \cancel{\qquad} & \cancel{\qquad} & \cancel{\qquad} & \cancel{\qquad} & \cancel{\qquad}  \\ 
 +
\cancel{\qquad} & \cancel{\qquad} & \cancel{\qquad} & \cancel{\qquad} & \cancel{\qquad} & \cancel{\qquad} & \cancel{\qquad} & \cancel{\qquad} & \cancel{\qquad} & \cancel{\qquad} & \cancel{\qquad}  \\
 +
 
 +
\end{array}
 +
</math>
  
 
==Proof 1==
 
==Proof 1==
 
<b>Definition</b>. An integer <math>N \in \mathbb{Z}</math> will be called <i>purchasable</i> if there exist nonnegative integers <math>a,b</math> such that <math>am+bn = N</math>.
 
<b>Definition</b>. An integer <math>N \in \mathbb{Z}</math> will be called <i>purchasable</i> if there exist nonnegative integers <math>a,b</math> such that <math>am+bn = N</math>.
  
We would like to prove that <math>mn-m-n</math> is the largest non-purchasable integer. We are required to show that (1) <math>mn-m-n</math> is non-purchasable, and (2) every <math>N > mn-m-n</math> is purchasable.
+
We would like to prove that <math>\text{ }mn-m-n\text{ }</math> is the largest non-purchasable integer. We are required to show that:
 +
 
 +
(1) <math>\text{ }mn-m-n\text{ }</math> is non-purchasable
 +
 
 +
(2) Every <math>N > mn-m-n</math> is purchasable
 +
 
Note that all purchasable integers are nonnegative, thus the set of non-purchasable integers is nonempty.
 
Note that all purchasable integers are nonnegative, thus the set of non-purchasable integers is nonempty.
  
Line 18: Line 56:
 
<b>Lemma</b>. For any integer <math>N</math>, there exists unique <math>(a_{N},b_{N}) \in \mathbb{Z} \times \{0,1,\ldots,m-1\}</math> such that <math>a_{N}m + b_{N}n = N</math>.
 
<b>Lemma</b>. For any integer <math>N</math>, there exists unique <math>(a_{N},b_{N}) \in \mathbb{Z} \times \{0,1,\ldots,m-1\}</math> such that <math>a_{N}m + b_{N}n = N</math>.
  
<i>Proof</i>: By the division algorithm, there exists <math>k</math> such that <math>0 \le y-km \le m-1</math>. <math>\square</math>
+
<i>Proof</i>: By the division algorithm, there exists one and only one <math>k</math> such that <math>0 \le y-km \le m-1</math>. <math>\square</math>
  
 
<b>Lemma</b>. <math>N</math> is purchasable if and only if <math>a_{N} \ge 0</math>.
 
<b>Lemma</b>. <math>N</math> is purchasable if and only if <math>a_{N} \ge 0</math>.
Line 28: Line 66:
  
 
==Proof 2==
 
==Proof 2==
 
 
We start with this statement taken from [[Fermat%27s_Little_Theorem#Proof_2_.28Inverses.29|Proof 2 of Fermat's Little Theorem]]:
 
We start with this statement taken from [[Fermat%27s_Little_Theorem#Proof_2_.28Inverses.29|Proof 2 of Fermat's Little Theorem]]:
  
Line 37: Line 74:
 
Clearly none of the <math>ia</math> for <math>1 \le i \le p-1</math> are divisible by <math>p</math>, so it suffices to show that all of the elements in <math>a \cdot S</math> are distinct. Suppose that <math>ai \equiv aj \pmod{p}</math> for <math>i \neq j</math>. Since <math>\text{gcd}\, (a,p) = 1</math>, by the cancellation rule, that reduces to <math>i \equiv j \pmod{p}</math>, which is a contradiction."
 
Clearly none of the <math>ia</math> for <math>1 \le i \le p-1</math> are divisible by <math>p</math>, so it suffices to show that all of the elements in <math>a \cdot S</math> are distinct. Suppose that <math>ai \equiv aj \pmod{p}</math> for <math>i \neq j</math>. Since <math>\text{gcd}\, (a,p) = 1</math>, by the cancellation rule, that reduces to <math>i \equiv j \pmod{p}</math>, which is a contradiction."
  
Because <math>m</math> and <math>n</math> are coprime, we know that multiplying the residues of <math>m</math> by <math>n</math> simply permutes these residues. Each of these permuted residues is representable in the form <math>am + bn</math> for nonnegative integers <math>a, b</math>, because <math>a</math> is <math>0</math> and <math>b</math> is the original residue. In addition, each number greater than that permuted residue which is congruent to it <math>\bmod m</math> is also representable, because is it simply the permuted residue summer with some number of <math>m</math>'s. The greatest of these residues is <math>(m-1)n</math>, so every number greater than or equal to it that is congruent to some residue of <math>m</math> (which is all numbers <math>\geq (m-1)n</math>) is representable. However, we can assume WLO that <math>m < n</math>. This would imply that <math>(m-2)n < (m-1)n-m</math>. All there are <math>m-1</math> numbers greater than <math>(m-1)n-m</math> and less than <math>(m-1)n</math>, and none of these are congruent to <math>(m-1)n \bmod m</math>. Therefore, these numbers are all congruent to some lesser permuted residue, and are thus representable.
+
Because <math>m</math> and <math>n</math> are coprime, we know that multiplying the residues of <math>m</math> by <math>n</math> simply permutes these residues. Each of these permuted residues is purchasable (using the definition from Proof 1), because, in the form <math>am+bn</math>, <math>a</math> is <math>0</math> and <math>b</math> is the original residue. We now prove the following lemma.
 +
 
 +
<b>Lemma</b>: For any nonnegative integer <math>c < m</math>, <math>cn</math> is the least purchasable number <math>\equiv cn \bmod m</math>.
 +
 
 +
<i>Proof</i>: Any number that is less than <math>cn</math> and congruent to it <math>\bmod m</math> can be represented in the form <math>cn-dm</math>, where <math>d</math> is a positive integer. If this is purchasable, we can say <math>cn-dm=am+bn</math> for some nonnegative integers <math>a, b</math>. This can be rearranged into <math>(a+d)m=(c-b)n</math>, which implies that <math>(a+d)</math> is a multiple of <math>n</math> (since <math>\gcd(m, n)=1</math>). We can say that <math>(a+d)=gn</math> for some positive integer <math>g</math>, and substitute to get <math>gmn=(c-b)n</math>. Because <math>c < m</math>, <math>(c-b)n < mn</math>, and <math>gmn < mn</math>. We divide by <math>mn</math> to get <math>g<1</math>. However, we defined <math>g</math> to be a positive integer, and all positive integers are greater than or equal to <math>1</math>. Therefore, we have a contradiction, and <math>cn</math> is the least purchasable number congruent to <math>cn \bmod m</math>. <math>\square</math>
  
If <math>(m-1)n-m=am+bn</math> for some positive integers <math>a</math> and <math>b</math>, then we can rearrange to find that <math>(a+1)m=(m-1-b)n</math>, which implies that <math>a+1</math> has to be some positive multiple of <math>n</math>. We set <math>(a+1)m=gmn</math> for some positive integer <math>g</math>. We can say <math>gmn=(m-1-b)n<mn</math>, and therefore <math>gmn<mn</math> and <math>g<1</math>. However, we said that <math>g</math> had to be a positive integer. Therefore, we have a contradiction, and <math>(m-1)n-m</math> is not representable.
+
This means that because <math>cn</math> is purchasable, every number that is greater than <math>cn</math> and congruent to it <math>\bmod m</math> is also purchasable (because these numbers are in the form <math>am+bn</math> where <math>b=c</math>). Another result of this Lemma is that <math>cn-m</math> is the greatest number <math>\equiv cn \bmod m</math> that is not purchasable. <math>c \leq m-1</math>, so <math>cn-m \leq (m-1)n-m=mn-m-n</math>, which shows that <math>mn-m-n</math> is the greatest number in the form <math>cn-m</math>. Any number greater than this and congruent to some <math>cn \bmod m</math> is purchasable, because that number is greater than <math>cn</math>. All numbers are congruent to some <math>cn</math>, and thus all numbers greater than <math>mn-m-n</math> are purchasable.
  
 
Putting it all together, we can say that for any coprime <math>m</math> and <math>n</math>, <math>mn-m-n</math> is the greatest number not representable in the form <math>am + bn</math> for nonnegative integers <math>a, b</math>. <math>\square</math>
 
Putting it all together, we can say that for any coprime <math>m</math> and <math>n</math>, <math>mn-m-n</math> is the greatest number not representable in the form <math>am + bn</math> for nonnegative integers <math>a, b</math>. <math>\square</math>
  
==Problems==
+
==Corollary==
 +
This corollary is based off of Proof 2, so it is necessary to read that proof before this corollary. We prove the following lemma.
 +
 
 +
<b>Lemma:</b> For any integer <math>k</math>, exactly one of the integers <math>k</math>, <math>mn-m-n-k</math> is not purchasable.
 +
 
 +
<i>Proof</i>: Because every number is congruent to some residue of <math>m</math> permuted by <math>n</math>, we can set <math>k \equiv cn \bmod m</math> for some <math>c</math>. We can break this into two cases.
 +
 
 +
<i>Case 1</i>: <math>k \leq cn-m</math>. This implies that <math>k</math> is not purchasable, and that <math>mn-m-n-k \geq mn-m-n-(cn-m) = n(m-1-c)</math>. <math>n(m-1-c)</math> is a permuted residue, and a result of the lemma in Proof 2 was that a permuted residue is the least number congruent to itself <math>\bmod m</math> that is purchasable. Therefore, <math>mn-m-n-k \equiv n(m-1-c) \bmod m</math> and <math>mn-m-n-k \geq n(m-1-c)</math>, so <math>mn-m-n-k</math> is purchasable.
 +
 
 +
<i>Case 2</i>: <math>k > cn-m</math>. This implies that <math>k</math> is purchasable, and that <math>mn-m-n-k < mn-m-n-(cn-m) = n(m-1-c)</math>. Again, because <math>n(m-1-c)</math> is the least number congruent to itself <math>\bmod m</math> that is purchasable, and because <math>mn-m-n-k \equiv n(m-1-c) \bmod m</math> and <math>mn-m-n-k < n(m-1-c)</math>, <math>mn-m-n-k</math> is not purchasable.
 +
 
 +
We now limit the values of <math>k</math> to all integers <math>0 \leq k \leq \frac{mn-m-n}{2}</math>, which limits the values of <math>mn-m-n-k</math> to <math>mn-m-n \geq mn-m-n-k \geq  \frac{mn-m-n}{2}</math>. Because <math>m</math> and <math>n</math> are coprime, only one of them can be a multiple of <math>2</math>. Therefore, <math>mn-m-n \equiv (0)(1)-0-1 \equiv -1 \equiv 1 \bmod 2</math>, showing that <math>\frac{mn-m-n}{2}</math> is not an integer and that <math>\frac{mn-m-n-1}{2}</math> and <math>\frac{mn-m-n+1}{2}</math> are integers. We can now set limits that are equivalent to the previous on the values of <math>k</math> and <math>mn-m-n-k</math> so that they cover all integers form <math>0</math> to <math>mn-m-n</math> without overlap: <math>0 \leq k \leq \frac{mn-m-n-1}{2}</math> and <math>\frac{mn-m-n+1}{2} \leq mn-m-n-k \leq mn-m-n</math>. There are <math>\frac{mn-m-n-1}{2}+1=\frac{(m-1)(n-1)}{2}</math> values of <math>k</math>, and each is paired with a value of <math>mn-m-n-k</math>, so we can make <math>\frac{(m-1)(n-1)}{2}</math> different ordered pairs of the form <math>(k, mn-m-n-k)</math>. The coordinates of these ordered pairs cover all integers from <math>0</math> to <math>mn-m-n</math> inclusive, and each contains exactly one not-purchasable integer, so that means that there are <math>\frac{(m-1)(n-1)}{2}</math> different not-purchasable integers from <math>0</math> to <math>mn-m-n</math>. All integers greater than <math>mn-m-n</math> are purchasable, so that means there are a total of <math>\frac{(m-1)(n-1)}{2}</math> integers <math>\geq 0</math> that are not purchasable.
 +
 
 +
In other words, for every pair of coprime integers <math>m, n</math>, there are exactly <math>\frac{(m-1)(n-1)}{2}</math> nonnegative integers that cannot be represented in the form <math>am + bn</math> for nonnegative integers <math>a, b</math>. <math>\square</math>
 +
 
 +
==Generalization==
 +
If <math>m</math> and <math>n</math> are not relatively prime, then we can simply rearrange <math>am+bn</math> into the form
 +
<cmath>\gcd(m,n) \left( a\frac{m}{\gcd(m,n)}+b\frac{n}{\gcd(m,n)} \right)</cmath>
 +
<math>\frac{m}{\gcd(m,n)}</math> and <math>\frac{n}{\gcd(m,n)}</math> are relatively prime, so we apply Chicken McNugget to find a bound
 +
<cmath>\frac{mn}{\gcd(m,n)^{2}}-\frac{m}{\gcd(m,n)}-\frac{n}{\gcd(m,n)}</cmath>
 +
We can simply multiply <math>\gcd(m,n)</math> back into the bound to get
 +
<cmath>\frac{mn}{\gcd(m,n)}-m-n=\textrm{lcm}(m, n)-m-n</cmath>
 +
Therefore, all multiples of <math>\gcd(m, n)</math> greater than <math>\textrm{lcm}(m, n)-m-n</math> are representable in the form <math>am+bn</math> for some positive integers <math>a, b</math>.
 +
 
 +
=Problems=
 +
 
 
===Introductory===
 
===Introductory===
*Marcy buys paint jars in containers of <math>2</math> and <math>7</math>.  What's the largest number of paint jars that Marcy can't obtain?
+
*Marcy buys paint jars in containers of <math>2</math> and <math>7</math>.  What's the largest number of paint jars that Marcy can't obtain?                                  
*Bay Area Rapid food sells chicken nuggets. You can buy packages of <math>11</math> or <math>7</math>. What is the largest integer <math>n</math> such that there is no way to buy exactly <math>n</math> nuggets? Can you Generalize ?(ACOPS)
+
 
 +
Answer: <math>5</math> containers
 +
 
 +
*Bay Area Rapid food sells chicken nuggets. You can buy packages of <math>11</math> or <math>7</math>. What is the largest integer <math>n</math> such that there is no way to buy exactly <math>n</math> nuggets? Can you Generalize ? (Source: The Art and Craft of Problem Solving)                                                                                                                                 
 +
 
 +
Answer: <math>n=59</math>
 +
 
 +
*If a game of American Football has only scores of field goals (<math>3</math> points) and touchdowns with the extra point (<math>7</math> points), then what is the greatest score that cannot be the score of a team in this football game (ignoring time constraints)?
 +
 
 +
Answer: <math>11</math> points
  
===Intermediate===
+
*The town of Hamlet has <math>3</math> people for each horse, <math>4</math> sheep for each cow, and <math>3</math> ducks for each person. Which of the following could not possibly be the total number of people, horses, sheep, cows, and ducks in Hamlet?
*Ninety-four bricks, each measuring <math>4''\times10''\times19'',</math> are to stacked one on top of another to form a tower 94 bricks tall.  Each brick can be oriented so it contributes <math>4''\,</math> or <math>10''\,</math> or <math>19''\,</math> to the total height of the tower.  How many different tower heights can be achieved using all ninety-four of the bricks? [[1994 AIME Problems/Problem 11|Source]]
 
  
===Olympiad===
+
<math>\textbf{(A) }41\qquad\textbf{(B) }47\qquad\textbf{(C) }59\qquad\textbf{(D) }61\qquad\textbf{(E) }66</math> (Source: [[2015 AMC 10B Problems/Problem 15|AMC 10B 2015 Problem 15]])
*On the real number line, paint red all points that correspond to integers of the form <math>81x+100y</math>, where <math>x</math> and <math>y</math> are positive integers. Paint the remaining integer point blue. Find a point <math>P</math> on the line such that, for every integer point <math>T</math>, the reflection of <math>T</math> with respect to <math>P</math> is an integer point of a different colour than <math>T</math>. (India TST)
 
  
*Let <math>S</math> be a set of integers (not necessarily positive) such that
+
Answer: <math>47\qquad\textbf{(B) }</math>
  
(a) there exist <math>a,b \in S</math> with <math>\gcd(a,b)=\gcd(a-2,b-2)=1</math>;
+
===Intermediate===
 +
*Ninety-four bricks, each measuring <math>4''\times10''\times19'',</math> are to stacked one on top of another to form a tower 94 bricks tall.  Each brick can be oriented so it contributes <math>4''\,</math> or <math>10''\,</math> or <math>19''\,</math> to the total height of the tower.  How many different tower heights can be achieved using all ninety-four of the bricks? (Source: [[1994 AIME Problems/Problem 11|AIME]])
  
(b) if <math>x</math> and <math>y</math> are elements of <math>S</math> (possibly equal), then <math>x^2-y</math> also belongs to <math>S</math>.
+
*Find the sum of all positive integers <math>n</math> such that, given an unlimited supply of stamps of denominations <math>5,n,</math> and <math>n+1</math> cents, <math>91</math> cents is the greatest postage that cannot be formed. (Source: [[2019 AIME II Problems/Problem 14|AIME II 2019 Problem 14]])
  
Prove that <math>S</math> is the set of all integers. (USAMO)
+
===Olympiad===
<math>3^6=729</math>
+
*On the real number line, paint red all points that correspond to integers of the form <math>81x+100y</math>, where <math>x</math> and <math>y</math> are positive integers. Paint the remaining integer points blue. Find a point <math>P</math> on the line such that, for every integer point <math>T</math>, the reflection of <math>T</math> with respect to <math>P</math> is an integer point of a different colour than <math>T</math>. (Source: India TST)
  
 
==See Also==
 
==See Also==

Revision as of 18:22, 24 February 2024

The Chicken McNugget Theorem (or Postage Stamp Problem or Frobenius Coin Problem) states that for any two relatively prime positive integers $m,n$, the greatest integer that cannot be written in the form $am + bn$ for nonnegative integers $a, b$ is $mn-m-n$.

A consequence of the theorem is that there are exactly $\frac{(m - 1)(n - 1)}{2}$ positive integers which cannot be expressed in the form $am + bn$. The proof is based on the fact that in each pair of the form $(k, mn-m-n-k)$, exactly one element is expressible.

Origins

There are many stories surrounding the origin of the Chicken McNugget theorem. However, the most popular by far remains that of the Chicken McNugget. Originally, McDonald's sold its nuggets in packs of 9 and 20. Math enthusiasts were curious to find the largest number of nuggets that could not have been bought with these packs, thus creating the Chicken McNugget Theorem (the answer worked out to be 151 nuggets). The Chicken McNugget Theorem has also been called the Frobenius Coin Problem or the Frobenius Problem, after German mathematician Ferdinand Frobenius inquired about the largest amount of currency that could not have been made with certain types of coins.

Proof Without Words

$\begin{array}{ccccccc} 0\mod{m}&1\mod{m}&2\mod{m}&...&...&...&(m-1)\mod{m}\\ \hline \cancel{0n}&1&2&&...&&m-1\\ \cancel{0n+m}&...&&\vdots&&...&\\ \cancel{0n+2m}&...&&\cancel{1n}&&...&\\ \cancel{0n+3m}&&&\cancel{1n+m}&&\vdots&\\ \cancel{0n+4m}&&&\cancel{1n+2m}&&\cancel{2n}&\\ \cancel{0n+5m}&&&\cancel{1n+3m}&&\cancel{2n+m}&\\ \vdots&&&\vdots&&\vdots&\\ \cancel{\qquad}&\cancel{\qquad}&\cancel{ \qquad}&\cancel{ \qquad}&\mathbf{(m-1)n-m}&\cancel{\qquad }&\cancel{\qquad }\\ \cancel{\qquad}&\cancel{\qquad}&\cancel{ \qquad}&\cancel{ \qquad}&\cancel{(m-1)n}&\cancel{\qquad }&\cancel{\qquad } \end{array}$


Example using m=$\color{magenta}11$ and n=$\color{blue}4$

$\begin{array}{ccccccccccc}   0 & 1 & 2 & 3 & \color{blue}\cancel{4}& 5 & 6 & 7 & \color{blue}\cancel{8} & 9 & 10 \\   \color{magenta}\cancel{11} & \color{blue}\cancel{12} & 13 & 14 & \cancel{15} & \color{blue}\cancel{16} & 17 & 18 & \cancel{19} & \color{blue}\cancel{20} & 21 \\  \cancel{22} & \cancel{23} & \color{blue}\cancel{24} & 25 & \cancel{26} & \cancel{27} & \color{blue}\cancel{28} & \color{red}\bold 29 & \cancel{30} & \cancel{31} & \color{blue}\cancel{32} \\  \cancel{33} & \cancel{34} & \cancel{35} & \color{blue}\cancel{36} & \cancel{37} & \cancel{38} & \cancel{39} & \color{blue}\cancel{40} & \cancel{41} & \cancel{42} & \cancel{43} \\  \cancel{44} & \cancel{ 45 } & \cancel{ 46 } & \cancel{ 47 } & \cancel{ 48 } & \cancel{ 49 } & \cancel{ 50 } & \cancel{ 51 } & \cancel{ 52 } & \cancel{ 53 } & \cancel{ 54 }\\   \cancel{55} & \cancel{ 56 } & \cancel{ 57 } & \cancel{ 58 } & \cancel{ 59 } & \cancel{ 60 } & \cancel{ 61 } & \cancel{ 62 } & \cancel{ 63 } & \cancel{ 64 } & \cancel{ 65 } \\    \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots  \\\ \cancel{\qquad} & \cancel{\qquad} & \cancel{\qquad} & \cancel{\qquad} & \cancel{\qquad} & \cancel{\qquad} & \cancel{\qquad} & \cancel{\qquad} & \cancel{\qquad} & \cancel{\qquad} & \cancel{\qquad}  \\   \cancel{\qquad} & \cancel{\qquad} & \cancel{\qquad} & \cancel{\qquad} & \cancel{\qquad} & \cancel{\qquad} & \cancel{\qquad} & \cancel{\qquad} & \cancel{\qquad} & \cancel{\qquad} & \cancel{\qquad}  \\   \end{array}$

Proof 1

Definition. An integer $N \in \mathbb{Z}$ will be called purchasable if there exist nonnegative integers $a,b$ such that $am+bn = N$.

We would like to prove that $\text{ }mn-m-n\text{ }$ is the largest non-purchasable integer. We are required to show that:

(1) $\text{ }mn-m-n\text{ }$ is non-purchasable

(2) Every $N > mn-m-n$ is purchasable

Note that all purchasable integers are nonnegative, thus the set of non-purchasable integers is nonempty.

Lemma. Let $A_{N} \subset \mathbb{Z} \times \mathbb{Z}$ be the set of solutions $(x,y)$ to $xm+yn = N$. Then $A_{N} = \{(x+kn,y-km) \;:\; k \in \mathbb{Z}\}$ for any $(x,y) \in A_{N}$.

Proof: By Bezout's Lemma, there exist integers $x',y'$ such that $x'm+y'n = 1$. Then $(Nx')m+(Ny')n = N$. Hence $A_{N}$ is nonempty. It is easy to check that $(Nx'+kn,Ny'-km) \in A_{N}$ for all $k \in \mathbb{Z}$. We now prove that there are no others. Suppose $(x_{1},y_{1})$ and $(x_{2},y_{2})$ are solutions to $xm+yn=N$. Then $x_{1}m+y_{1}n = x_{2}m+y_{2}n$ implies $m(x_{1}-x_{2}) = n(y_{2}-y_{1})$. Since $m$ and $n$ are coprime and $m$ divides $n(y_{2}-y_{1})$, $m$ divides $y_{2}-y_{1}$ and $y_{2} \equiv y_{1} \pmod{m}$. Similarly $x_{2} \equiv x_{1} \pmod{n}$. Let $k_{1},k_{2}$ be integers such that $x_{2}-x_{1} = k_{1}n$ and $y_{2}-y_{1} = k_{2}m$. Then $m(-k_{1}n) = n(k_{2}m)$ implies $k_{1} = -k_{2}.$ We have the desired result. $\square$

Lemma. For any integer $N$, there exists unique $(a_{N},b_{N}) \in \mathbb{Z} \times \{0,1,\ldots,m-1\}$ such that $a_{N}m + b_{N}n = N$.

Proof: By the division algorithm, there exists one and only one $k$ such that $0 \le y-km \le m-1$. $\square$

Lemma. $N$ is purchasable if and only if $a_{N} \ge 0$.

Proof: If $a_{N} \ge 0$, then we may simply pick $(a,b) = (a_{N},b_{N})$ so $N$ is purchasable. If $a_{N} < 0$, then $a_{N}+kn < 0$ if $k \le 0$ and $b_{N}-km < 0$ if $k > 0$, hence at least one coordinate of $(a_{N}+kn,b_{N}-km)$ is negative for all $k \in \mathbb{Z}$. Thus $N$ is not purchasable. $\square$

Thus the set of non-purchasable integers is $\{xm+yn \;:\; x<0,0 \le y \le m-1\}$. We would like to find the maximum of this set. Since both $m,n$ are positive, the maximum is achieved when $x = -1$ and $y = m-1$ so that $xm+yn = (-1)m+(m-1)n = mn-m-n$.

Proof 2

We start with this statement taken from Proof 2 of Fermat's Little Theorem:

"Let $S = \{1,2,3,\cdots, p-1\}$. Then, we claim that the set $a \cdot S$, consisting of the product of the elements of $S$ with $a$, taken modulo $p$, is simply a permutation of $S$. In other words,

\[S \equiv \{1a, 2a, \cdots, (p-1)a\} \pmod{p}.\]


Clearly none of the $ia$ for $1 \le i \le p-1$ are divisible by $p$, so it suffices to show that all of the elements in $a \cdot S$ are distinct. Suppose that $ai \equiv aj \pmod{p}$ for $i \neq j$. Since $\text{gcd}\, (a,p) = 1$, by the cancellation rule, that reduces to $i \equiv j \pmod{p}$, which is a contradiction."

Because $m$ and $n$ are coprime, we know that multiplying the residues of $m$ by $n$ simply permutes these residues. Each of these permuted residues is purchasable (using the definition from Proof 1), because, in the form $am+bn$, $a$ is $0$ and $b$ is the original residue. We now prove the following lemma.

Lemma: For any nonnegative integer $c < m$, $cn$ is the least purchasable number $\equiv cn \bmod m$.

Proof: Any number that is less than $cn$ and congruent to it $\bmod m$ can be represented in the form $cn-dm$, where $d$ is a positive integer. If this is purchasable, we can say $cn-dm=am+bn$ for some nonnegative integers $a, b$. This can be rearranged into $(a+d)m=(c-b)n$, which implies that $(a+d)$ is a multiple of $n$ (since $\gcd(m, n)=1$). We can say that $(a+d)=gn$ for some positive integer $g$, and substitute to get $gmn=(c-b)n$. Because $c < m$, $(c-b)n < mn$, and $gmn < mn$. We divide by $mn$ to get $g<1$. However, we defined $g$ to be a positive integer, and all positive integers are greater than or equal to $1$. Therefore, we have a contradiction, and $cn$ is the least purchasable number congruent to $cn \bmod m$. $\square$

This means that because $cn$ is purchasable, every number that is greater than $cn$ and congruent to it $\bmod m$ is also purchasable (because these numbers are in the form $am+bn$ where $b=c$). Another result of this Lemma is that $cn-m$ is the greatest number $\equiv cn \bmod m$ that is not purchasable. $c \leq m-1$, so $cn-m \leq (m-1)n-m=mn-m-n$, which shows that $mn-m-n$ is the greatest number in the form $cn-m$. Any number greater than this and congruent to some $cn \bmod m$ is purchasable, because that number is greater than $cn$. All numbers are congruent to some $cn$, and thus all numbers greater than $mn-m-n$ are purchasable.

Putting it all together, we can say that for any coprime $m$ and $n$, $mn-m-n$ is the greatest number not representable in the form $am + bn$ for nonnegative integers $a, b$. $\square$

Corollary

This corollary is based off of Proof 2, so it is necessary to read that proof before this corollary. We prove the following lemma.

Lemma: For any integer $k$, exactly one of the integers $k$, $mn-m-n-k$ is not purchasable.

Proof: Because every number is congruent to some residue of $m$ permuted by $n$, we can set $k \equiv cn \bmod m$ for some $c$. We can break this into two cases.

Case 1: $k \leq cn-m$. This implies that $k$ is not purchasable, and that $mn-m-n-k \geq mn-m-n-(cn-m) = n(m-1-c)$. $n(m-1-c)$ is a permuted residue, and a result of the lemma in Proof 2 was that a permuted residue is the least number congruent to itself $\bmod m$ that is purchasable. Therefore, $mn-m-n-k \equiv n(m-1-c) \bmod m$ and $mn-m-n-k \geq n(m-1-c)$, so $mn-m-n-k$ is purchasable.

Case 2: $k > cn-m$. This implies that $k$ is purchasable, and that $mn-m-n-k < mn-m-n-(cn-m) = n(m-1-c)$. Again, because $n(m-1-c)$ is the least number congruent to itself $\bmod m$ that is purchasable, and because $mn-m-n-k \equiv n(m-1-c) \bmod m$ and $mn-m-n-k < n(m-1-c)$, $mn-m-n-k$ is not purchasable.

We now limit the values of $k$ to all integers $0 \leq k \leq \frac{mn-m-n}{2}$, which limits the values of $mn-m-n-k$ to $mn-m-n \geq mn-m-n-k \geq  \frac{mn-m-n}{2}$. Because $m$ and $n$ are coprime, only one of them can be a multiple of $2$. Therefore, $mn-m-n \equiv (0)(1)-0-1 \equiv -1 \equiv 1 \bmod 2$, showing that $\frac{mn-m-n}{2}$ is not an integer and that $\frac{mn-m-n-1}{2}$ and $\frac{mn-m-n+1}{2}$ are integers. We can now set limits that are equivalent to the previous on the values of $k$ and $mn-m-n-k$ so that they cover all integers form $0$ to $mn-m-n$ without overlap: $0 \leq k \leq \frac{mn-m-n-1}{2}$ and $\frac{mn-m-n+1}{2} \leq mn-m-n-k \leq mn-m-n$. There are $\frac{mn-m-n-1}{2}+1=\frac{(m-1)(n-1)}{2}$ values of $k$, and each is paired with a value of $mn-m-n-k$, so we can make $\frac{(m-1)(n-1)}{2}$ different ordered pairs of the form $(k, mn-m-n-k)$. The coordinates of these ordered pairs cover all integers from $0$ to $mn-m-n$ inclusive, and each contains exactly one not-purchasable integer, so that means that there are $\frac{(m-1)(n-1)}{2}$ different not-purchasable integers from $0$ to $mn-m-n$. All integers greater than $mn-m-n$ are purchasable, so that means there are a total of $\frac{(m-1)(n-1)}{2}$ integers $\geq 0$ that are not purchasable.

In other words, for every pair of coprime integers $m, n$, there are exactly $\frac{(m-1)(n-1)}{2}$ nonnegative integers that cannot be represented in the form $am + bn$ for nonnegative integers $a, b$. $\square$

Generalization

If $m$ and $n$ are not relatively prime, then we can simply rearrange $am+bn$ into the form \[\gcd(m,n) \left( a\frac{m}{\gcd(m,n)}+b\frac{n}{\gcd(m,n)} \right)\] $\frac{m}{\gcd(m,n)}$ and $\frac{n}{\gcd(m,n)}$ are relatively prime, so we apply Chicken McNugget to find a bound \[\frac{mn}{\gcd(m,n)^{2}}-\frac{m}{\gcd(m,n)}-\frac{n}{\gcd(m,n)}\] We can simply multiply $\gcd(m,n)$ back into the bound to get \[\frac{mn}{\gcd(m,n)}-m-n=\textrm{lcm}(m, n)-m-n\] Therefore, all multiples of $\gcd(m, n)$ greater than $\textrm{lcm}(m, n)-m-n$ are representable in the form $am+bn$ for some positive integers $a, b$.

Problems

Introductory

  • Marcy buys paint jars in containers of $2$ and $7$. What's the largest number of paint jars that Marcy can't obtain?

Answer: $5$ containers

  • Bay Area Rapid food sells chicken nuggets. You can buy packages of $11$ or $7$. What is the largest integer $n$ such that there is no way to buy exactly $n$ nuggets? Can you Generalize ? (Source: The Art and Craft of Problem Solving)

Answer: $n=59$

  • If a game of American Football has only scores of field goals ($3$ points) and touchdowns with the extra point ($7$ points), then what is the greatest score that cannot be the score of a team in this football game (ignoring time constraints)?

Answer: $11$ points

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

$\textbf{(A) }41\qquad\textbf{(B) }47\qquad\textbf{(C) }59\qquad\textbf{(D) }61\qquad\textbf{(E) }66$ (Source: AMC 10B 2015 Problem 15)

Answer: $47\qquad\textbf{(B) }$

Intermediate

  • Ninety-four bricks, each measuring $4''\times10''\times19'',$ are to stacked one on top of another to form a tower 94 bricks tall. Each brick can be oriented so it contributes $4''\,$ or $10''\,$ or $19''\,$ to the total height of the tower. How many different tower heights can be achieved using all ninety-four of the bricks? (Source: AIME)
  • Find the sum of all positive integers $n$ such that, given an unlimited supply of stamps of denominations $5,n,$ and $n+1$ cents, $91$ cents is the greatest postage that cannot be formed. (Source: AIME II 2019 Problem 14)

Olympiad

  • On the real number line, paint red all points that correspond to integers of the form $81x+100y$, where $x$ and $y$ are positive integers. Paint the remaining integer points blue. Find a point $P$ on the line such that, for every integer point $T$, the reflection of $T$ with respect to $P$ is an integer point of a different colour than $T$. (Source: India TST)

See Also