You are on page 1of 5

Chapter 12

Diophantine Equations

12.1 Notes
A Diophantine equation (named after Diophantus of Alexandria) is an equation
where we only want integer solutions.

Linear Diophantine Equations


In their simplest form, linear Diophantine equations take the form
ax + by = c
where a, b, c are known integers, and x and y are unknowns.
Theorem 12.1.1 (Bézout’s identity). If gcd(a, b) is a divisor of c, then the Diophantine
equation ax + by = c has integer solutions.
If gcd(a, b) is not a divisor of c, then ax + by = c does not have integer solutions.
If (x0 , y0 ) is a solution, then all solutions can be parametrized in the form (x, y) =
(x0 + bt, y0 − at) where t is any integer.
Example 12.1.2. Find all integer solutions to the Diophantine equation 10x + 11y = 1.
Solution. Note that (x, y) = (−1, 1) is a solution. Then the solutions are of the form
(x, y) = (−1 + 11t, 1 − 10t) .

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):

(29, 31) → (31, 29)


→ (2, 29)

Note that 2 is obviously a linear combination of 31 and 29 (2 = 29 × (−1) + 31 × 1). Every


time we apply the substitution in the Euclidean algorithm, we can replace what we already
know about linear combinations of previously-computed terms:

(29, 2) → (27, 2) → . . . → (1, 2)

We subtracted 2 from 29 fourteen times to obtain 1, and knowing that 2 = 29×(−1)+31×1,


we can express 1 as a linear combination of 29 and 31:

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

Other Diophantine equations


Of course, most equations we deal with are not linear. Oftentimes we are interested in
solving quadratic equations. Finding Pythagorean triples can be thought of as solving
a quadratic Diophantine equation.

Definition 12.1.6. A Pythagorean triple is an ordered triple (a, b, c) of positive integers


with a < b < c such that a2 + b2 = c2 . A primitive Pythagorean triple is any
Pythagorean triple (a, b, c) with gcd(a, b, c) = 1.

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).

Using modular arithmetic


Some Diophantine equations can be solved with help of modular arithmetic. In some
cases where no integer solutions can exist, you can prove that no solutions exist by consid-
ering the equation modulo m, for some choice of m.

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) .

Fermat’s Last Theorem (Optional)


Perhaps the best known Diophantine equation is the following:

an + bn = cn

where a, b, c are positive integers, and n ≥ 3.

Theorem 12.1.8 (Fermat’s Last Theorem). The equation an + bn = cn has no positive


integer solutions (a, b, c, n) where n ≥ 3.

The proof was famously published in 1995 by Andrew Wiles.

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

(2z)4 = 8x3 y + 8xy 3


= (x4 + 4x3 y + 6x2 y 2 + 4xy 3 + y 4 ) − (x4 − 4x3 y + 6x2 y 2 − 4xy 3 + y 4 )
= (x + y)4 − (x − y)4 ,

which has no integer solutions by Fermat’s Last Theorem unless x − y = 0, or 2z = 0. This


gives x = y, since z cannot be 0. Therefore, plugging back in gives x = z. So the only
possible solutions are of the form (x, x, x).

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.

3. (CHMMC-2010 Winter-Individual-9) Let A and B be points in the plane such that


AB = 30. A circle with integer radius passes through A and B. A point C is
constructed on the circle such that AC is a diameter of the circle. Compute all
possible radii of the circle such that BC is a positive integer.

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?

(A) 30 (B) 31 (C) 32 (D) 33 (E) 34

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?

3. (AMC10-2012-A24) Let a, b, and c be positive integers with a ≥ b ≥ c such that

a2 − b2 − c2 + ab = 2011 and a2 + 3b2 + 3c2 − 3ab − 2ac − 2bc = −1997.

What is a?

(A) 249 (B) 250 (C) 251 (D) 252 (E) 253

4. (AMC10-2018-A25) For a positive integer n and nonzero digits a, b, and c, let An be


the n-digit integer each of whose digits is equal to a; let Bn be the n-digit integer
each of whose digits is equal to b, and let Cn be the 2n-digit (not n-digit) integer
each of whose digits is equal to c. What is the greatest possible value of a + b + c for
which there are at least two values of n such that Cn − Bn = A2n ?

(A) 12 (B) 14 (C) 16 (D) 18 (E) 20

54

You might also like