Professional Documents
Culture Documents
Diophantine Equations
12.1 Notes
A Diophantine equation (named after Diophantus of Alexandria) is an equation
where we only want integer solutions.
Computing a solution
In this part, we will assume without loss of generality that c = 1, and that gcd(a, b) = 1.
To solve ax + by = 1, we can express 1 as a linear combination of a and b. We can do
so by applying the Euclidean algorithm, as shown in the following example:
50
MC35N Chapter 12. Diophantine Equations
Example 12.1.3. Find all integer solutions to the equation 29x + 31y = 1.
Proof. To find a solution, we can compute gcd(29, 31) using the Euclidean algorithm (even
though we know it is 1):
1 = 29 − 14 × (29 × (−1) + 31 × 1)
= 15 × 29 − 14 × 31
So one solution is (x, y) = (15, −14). Then all solutions are of the form (x, y) = (15 + 31t, −14 − 29t) .
We can use this method to compute solutions to systems of congruences whose solutions
are guaranteed by the Chinese remainder theorem.
Chicken McNuggets
The postage stamp theorem (humorously called the Chicken McNugget theo-
rem) gives a useful result on non-negative integer solutions of linear Diophantine equations:
Theorem 12.1.4 (Postage Stamp Theorem). If a and b are relatively prime positive
integers, then the greatest integer that cannot be written in the form ax + by for non-
negative integers x and y is ab − a − b.
Example 12.1.5. A fast food restaurant sells chicken nuggets in packages of 9 and 20.
What is the largest number of chicken nuggets one cannot buy, assuming none are eaten?
Solution. By the postage stamp theorem, the largest number that one cannot buy is 9 ·
20 − 9 − 20 = 151 .
51
MC35N Chapter 12. Diophantine Equations
In fact, the general solution for a Pythagorean triple is k(m2 − n2 , 2mn, m2 + n2 ). for
integers k, m, n. If m, n are relatively prime and have different parity, and k = 1, then this
gives a primitive Pythagorean triple - for example, m = 5, n = 2, k = 1 gives (21, 20, 29).
Example 12.1.7. Find all positive integer solutions (m, n) to the equation m3 − 3 = n!.
Solution. We can consider modulo 3. In this case, if n ≥ 3, then the RHS is divisible by 3,
so m is also divisible by 3.
However, considering modulo 9 gives us more information. If n ≥ 6, then the RHS is
divisible by 9. However, m3 − 3 ≡ 0 (mod 9) iff m3 ≡ 3 (mod 9) which cannot happen
(since 3 must completely divide m3 ). Thus there are no solutions where n ≥ 6.
We can simply try n = 1, 2, 3, 4, 5 to obtain the only integer solution (m, n) = (3, 4) .
an + bn = cn
52
MC35N Chapter 12. Diophantine Equations
Example 12.1.9 (Folklore). Find all positive integer solutions (x, y, z) to the equation
xy(x2 + y 2 ) = 2z 4 .
Solution. We multiply both sides by 8, getting 8xy(x2 + y 2 ) = 16z 4 . If you look very
closely, you may notice that
12.2 Examples
1. (HMMT Feb-2004-Guts-13) Find all positive integer solutions (m, n) to the following
equation:
m2 = 1! + 2! + ... + n!.
2. (Classic) If x and y are co-prime, find a closed-form expression for the number of
integers k such that ax + by = k has no solutions for non-negative integers a, b.
12.3 Exercises
1. (AMC10-2010-B24) A high school basketball game between the Raiders and Wild-
cats was tied at the end of the first quarter. The number of points scored by the
Raiders in each of the four quarters formed an increasing geometric sequence, and
the number of points scored by the Wildcats in each of the four quarters formed an
increasing arithmetic sequence. At the end of the fourth quarter, the Raiders had
won by one point. Neither team scored more than 100 points. What was the total
number of points scored by the two teams in the first half?
53
MC35N Chapter 12. Diophantine Equations
2. (Lehigh MC-2004-31) What is the sum of all positive integers n for which 28 +211 +2n
is a perfect square?
What is a?
(A) 249 (B) 250 (C) 251 (D) 252 (E) 253
54