Module 3.4 · Number Theory
Diophantine equations
A Diophantine equation is an equation where only integer solutions count. There is no single method for all of them, but AIME problems almost always yield to one of a handful of moves: solve a linear equation with Bézout, factor (often with Simon's Favorite Factoring Trick), parametrize Pythagorean triples, rule out cases with a modulus, or recognize a Pell equation. This module teaches each move and when to reach for it.
Linear equations
Linear Diophantine equations
has integer solutions if and only if divides . If is one solution, all solutions are
Why. Bézout's identity says for some integers (the Euclidean algorithm run backward finds them), so if you can scale up to hit . Conversely divides the left side, so it must divide . For the general solution: if , then . Dividing by , with coprime, so .
To count positive solutions, find one solution, write the general one, and count the values of that keep both variables in range.
Chicken McNugget theorem
The Frobenius number for two coins
If are coprime positive integers, the largest integer that is not of the form with is . Exactly positive integers are not representable.
Why. Any can be written with a unique (choose with ). Then is representable with nonnegative coefficients exactly when this is , that is, . The largest failure takes and : . For the count, is representable iff is not (for ), so exactly half of those numbers fail.
Factoring
If an equation has a product and linear terms, complete the rectangle:
This is Simon's Favorite Factoring Trick. The right side is a fixed number, so solutions correspond to its factor pairs. Count positive divisors and then check which factor pairs keep in range, including negative factor pairs.
The same idea handles differences of squares, , where the two factors must have the same parity.
Worked example: Factoring trick
Find all positive integer solutions of .
Add : . With , we need and . Factor pairs of : work, while and make . The solutions are .
Pythagorean triples
All Pythagorean triples
Every primitive triple () with and even has the form
with , and odd. Every triple is times a primitive one.
Sketch. In a primitive triple exactly one leg is even; say . Then , and are coprime integers whose product is the square . Coprime numbers whose product is a square are both squares: , .
Often you don't even need the formula: with a known leg , write and count factor pairs of the same parity.
Worked example: Fixed perimeter
Find all right triangles with integer sides and perimeter .
The perimeter of is , so with . Try : , , giving . Try : , , giving . Other pairs have that either don't divide or break the conditions ( has even). So there are exactly two triangles.
Ruling out solutions with a modulus
To show an equation has no solutions, reduce it modulo something where squares (or cubes, or powers) take few values. Good moduli: and for squares (), or for cubes, , , .
Worked example: No solutions
Show that has no integer solutions.
Mod : , and , so and are both odd. Then mod : , so . But . Contradiction.
Pell equations
For a non-square , the equation has infinitely many positive solutions. If is the smallest, all of them come from
The reason: is multiplicative in the sense that the "norm" of a product equals the product of norms, so powers of a solution are solutions. (That these are all the solutions takes more work; you can quote it.) For , starting from : , then , and so on.
Common mistake
When counting factor pairs, don't forget negative pairs and don't forget parity. For , both factors could be negative; check whether that's consistent with . For , the factors and must both be even or both odd.
Practice
How many ordered pairs of positive integers satisfy ?
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
A store sells stickers only in packs of and packs of . How many positive integers are not the total number of stickers in some purchase?
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
How many ordered pairs of positive integers satisfy ?
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
How many ordered pairs of positive integers satisfy ?
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
How many right triangles with integer side lengths have a leg of length ? (Triangles that are congruent count once.)
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
How many ordered triples of nonnegative integers satisfy ?
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
Find the sum of all positive integers such that is a perfect square.
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
Find the largest positive integer such that is a perfect square.
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
Real contest practice
- 2015 AIME I, Problem 3: a prime with a perfect cube; factor .
- 1999 AIME, Problem 3: when a quadratic in is a perfect square; complete the square and factor a difference of squares.