Skip to content
Number Theory · Chapter 21

Diophantine Equations

Equations where every answer must be a whole number: factor them, list the factor pairs, and let the integers do the work.

You'll need
open on YouTube
21.10%

Quadratic Factorizations

In this section you will be able to spot squares inside a number or an expression, then split it into two factors with a² − b² = (a − b)(a + b).

Can you work out 53 × 47 in your head? It looks hard. But 53 × 47 = (50 + 3)(50 − 3) = 2500 − 9 = 2491. Squares hide inside products!

A Diophantine equation is an equation where the answers must be whole numbers. That one rule is a superpower. Often one equation with two unknowns is enough.

The trick is to factor. Once a number is written as a product, you can list its factor pairs. Look for squares: a difference of two squares always splits into two factors.

Exploreplay first, formulas later

7² − 3² = 4 × 10 = 40

a7
b3
−3²a = 7a = 7
72−32=4×10=407^2 - 3^2 = 4 \times 10 = 40

7² − 3² = 4 × 10 = 40

Name it

Remark 21.0.1

Diophantine equation problems often involve having to rewrite numbers and expressions into variables and combining the use of algebra and number theory. Essentially, they are equations with integer solutions.

Concept 21.0.2

With algebraic equations, if you have nn variables to solve for, you need nn equations. But for Diophantine equations this isn't true, since we have one added condition: every variable is an integer. This condition is the key that lets us solve Diophantine equations.

Theorem 21.1.1 · Difference of Squares

x2−y2=(x−y)(x+y)x^2 - y^2 = (x - y)(x + y)

Theorem 21.1.2 · Binomial Square Expansions

(x+y)2=x2+2xy+y2=(x−y)2+4xy(x + y)^2 = x^2 + 2xy + y^2 = (x - y)^2 + 4xy
(x−y)2=x2−2xy+y2=(x+y)2−4xy(x - y)^2 = x^2 - 2xy + y^2 = (x + y)^2 - 4xy
(x+y)2+(x−y)2=2(x2+y2)(x + y)^2 + (x - y)^2 = 2(x^2 + y^2)
(x+y)2−(x−y)2=4xy(x + y)^2 - (x - y)^2 = 4xy
(x+y+z)2=x2+y2+z2+2(xy+yz+xz)(x + y + z)^2 = x^2 + y^2 + z^2 + 2(xy + yz + xz)

Watch itpredict, then reveal

Example 21.3

Omega Learn

How many factors does the number 9984 have?

100² − 4² = 96 × 104 = 9,984

−4²a = 100a = 100
1002−42=96×104=9,984100^2 - 4^2 = 96 \times 104 = 9{,}984

100² − 4² = 96 × 104 = 9,984

  1. 1

    9984 is very close to a round number. Which perfect square is just above it, and by how much?

    Predict first:
open on YouTube

Example 21.4

Omega Learn

How many values of nn from 1 to 100 make 16n−2×4n+116^n - 2 \times 4^n + 1 a multiple of 49?

  1. 1

    Do you notice any of the factorizations in the expression?

Try it

Problem 21.5.3

AMC 8

How many digits are in the product 45⋅5104^5 \cdot 5^{10}?

Problem 21.5.7

AMC 8

What is the correct ordering of the three numbers, 10810^8, 5125^{12}, and 2242^{24}?

Contest cornerreal contest problems

Problem 21.5.19(additional)

EMCC

What is the largest positive 2-digit factor of 322011−2220113^{2^{2011}} - 2^{2^{2011}}?

Problem 21.5.20(additional)

MATHCOUNTS

If mm and nn are positive integers where m2+14m−32=3nm^2 + 14m - 32 = 3^n, what is the value of m+nm + n?

Checkpoint for section 21.1

Get 2 of 3 right to master this section. One try each, no hints.
1

Use the difference of squares to compute 532−47253^2 - 47^2.

2

If x+y=7x + y = 7 and xy=10xy = 10, what is x2+y2x^2 + y^2?

3

How many pairs of positive integers (x,y)(x, y) satisfy x2−y2=15x^2 - y^2 = 15?

21.20%

Simon’s Favorite Factoring Trick

In this section you will be able to factor equations with xy, x and y terms by adding the magic number to both sides (Simon's Favorite Factoring Trick).

Find whole numbers with xy + x + y = 14. Guessing is slow. Add 1 to both sides and the left side snaps into (x + 1)(y + 1) = 15. Now you just need the factors of 15!

Simon’s Favorite Factoring Trick (SFFT for short) works whenever you see an xy term, an x term and a y term. Picture a rectangle. The xy, x and y terms are three of its pieces. The missing corner is the magic number.

Add the magic number to both sides. Then list the factor pairs of the right side, and turn each pair back into x and y.

Exploreplay first, formulas later

xy + x + y = 14 becomes (x + 1)(y + 1) = 15: 2 solutions (2, 4), (4, 2)

x coefficient1
y coefficient1
right side14
xy+x+y=14xy + x + y = 14
x1y1xyyx?

xy + x + y = 14. Add the magic number to both sides.

Name it

Theorem 21.2.1 · Simon’s Favorite Factoring Trick

xy+kx+jy+jk=(x+j)(y+k)xy + kx + jy + jk = (x + j)(y + k)

Watch itpredict, then reveal

Example 21.5

Find the sum of all possible distinct values of x+yx + y where xx and yy are positive integers such that

1x+1y=12\frac{1}{x} + \frac{1}{y} = \frac{1}{2}

xy − 2x − 2y = 0 becomes (x − 2)(y − 2) = 4: 3 solutions (3, 6), (4, 4), (6, 3)

xy−2x−2y=0xy - 2x - 2y = 0
x−2y−2xy−2y−2x?

xy − 2x − 2y = 0. Add the magic number to both sides.

  1. 1

    How can we simplify this problem by removing the denominators?

Try it

Problem 21.5.5

AMC 8

A 2-digit number is such that the product of the digits plus the sum of the digits is equal to the number. What is the units digit of the number?

Problem 21.5.18(additional)

AMC 10

A two-digit positive integer is said to be cuddly if it is equal to the sum of its nonzero tens digit and the square of its units digit. How many two-digit positive integers are cuddly?

Contest cornerreal contest problems

Problem 21.5.16(additional)

AMC 12

In multiplying two positive integers aa and bb, Ron reversed the digits of the two-digit number aa. His erroneous product was 161. What is the correct value of the product aa and bb?

Problem 21.5.10

AMC 8

A baseball league consists of two four-team divisions. Each team plays every other team in its division N games. Each team plays every team in the other division M games with N>2MN > 2M and M>4M > 4. Each team plays a 76 game schedule. How many games does a team play within its own division?

Checkpoint for section 21.2

Get 2 of 3 right to master this section. One try each, no hints.
1

Rewrite xy+3x+2y=10xy + 3x + 2y = 10 with Simon's Favorite Factoring Trick as (x+2)(y+3)=N(x + 2)(y + 3) = N. What is NN?

2

How many ordered pairs of positive integers (x,y)(x, y) satisfy xy+x+y=14xy + x + y = 14?

3

Positive integers xx and yy satisfy xy−3x−3y=0xy - 3x - 3y = 0 and x<yx < y. What is the largest possible value of yy?

21.30%

Interesting Examples

In this section you will be able to turn word puzzles into equations. Digits become variables, and whole-number rules finish the job.

Take 952 and flip it: 259. Subtract: 952 − 259 = 693 = 99 × 7. Try another number. You get a multiple of 99 every time!

Write a 3-digit number as 100h + 10t + u, with digits h, t and u. Its reversal is 100u + 10t + h. Subtract, and the tens digit cancels: you get 99(h − u).

Every digit is a whole number from 0 to 9. That short list of options is what makes these puzzles solvable.

Exploreplay first, formulas later

952 − 259 = 693 = 99 × 7

hundreds digit h9
tens digit t5
units digit u2
original
reversed
952 − 259 = 693 = 99 × (h − u) = 99 × 7

952 − 259 = 693 = 99 × 7

Watch itpredict, then reveal

Example 21.1

Omega Learn

The digits of a 3 digit number are reversed. The original number is 594 greater than the new number. What is the largest possible value for the original number?

531 − 135 = 396 = 99 × 4; 40 numbers give 594

hundreds digit h5
tens digit t3
units digit u1
original
reversed
531 − 135 = 396 = 99 × (h − u) = 99 × 4
Goal: original − reversed = 594. You need h − u = 6.

531 − 135 = 396 = 99 × 4. Target 594.

  1. 1

    How can we turn a 3 digit number into variables?

Example 21.2

Omega Learn

The digits of a 2 digit number with tens digit 7 is reversed. The digits of a 3 digit number with hundreds digit 3 and tens digit 5 is also reversed. The sum of both of the new reversed numbers is 288 more than the sum of the original 2 numbers. Find the sum of the 2 original numbers.

  1. 1

    Name the unknown digits. How can you write the two original numbers?

open on YouTube

Example 21.6

AMC 8

Each of the points AA, BB, CC, DD, EE, and FF in the figure below represents a different digit from 1 to 6. Each of the five lines shown passes through some of these points. The digits along each line are added to produce five sums, one for each line. The total of the five sums is 47. What is the digit represented by BB?

  1. 1

    List the points on each line. Which point lies on the most lines?

    Predict first:
open on YouTube

Try it

Problem 21.5.14(additional)

After the digits of a 3 digit number are reversed, the number is 297 more than the original number. What's the largest possible value for the original number?

Problem 21.5.15(additional)

AMC 8

The hundreds digit of a three-digit number is 2 more than the units digit. The digits of the three-digit number are reversed, and the result is subtracted from the original three-digit number. What is the units digit of the result?

Problem 21.5.1

AMC 8

Peter, Emma, and Kyler played chess with each other. Peter won 4 games and lost 2 games. Emma won 3 games and lost 3 games. If Kyler lost 3 games, how many games did he win?

Contest cornerreal contest problems

Problem 21.5.6

AMC 8

In the multiplication problem below AA, BB, CC, DD are different digits. What is A+BA + B?

A B A×C DC D C D\begin{array}{r} A\,B\,A \\ \times \quad C\,D \\ \hline C\,D\,C\,D \end{array}

Problem 21.5.17(additional)

AMC 12

A palindrome, such as 83438, is a number that remains the same when its digits are reversed. The numbers xx and x+32x + 32 are three-digit and four-digit palindromes, respectively. What is the sum of the digits of xx?

Problem 21.5.9

AMC 8

After Euclid High School's last basketball game, it was determined that 14\frac{1}{4} of the team's points were scored by Alexa and 27\frac{2}{7} were scored by Brittany. Chelsea scored 15 points. None of the other 7 team members scored more than 2 points. What was the total number of points scored by the other 7 team members?

Problem 21.5.22(additional)

AMC 10

In the United States, coins have the following thicknesses: penny, 1.55 mm; nickel, 1.95 mm; dime, 1.35 mm; quarter, 1.75 mm. If a stack of these coins is exactly 14 mm high, how many coins are in the stack?

Checkpoint for section 21.3

Get 2 of 3 right to master this section. One try each, no hints.
1

A 3-digit number minus its reversal is 396. What is the hundreds digit minus the units digit?

2

A 2-digit number is 27 more than its reversal. What is the largest such number?

3

How many 3-digit numbers are exactly 198 more than their reversal?

21.40%

Cubic Factorizations (Optional)

In this section you will be able to factor sums and differences of cubes, and expand (x + y)³.

Is 999 prime? It’s 1000 − 1 = 10³ − 1³. Cubes factor too: 999 = 9 × 111.

This section is optional. Cubes don’t split as neatly as squares, but a³ − b³ always has the factor a − b. Also, a³ + b³ always has the factor a + b.

Exploreplay first, formulas later

5³ − 2³ = 3 × 39 = 117

a5
b2
first factor
a−b=5−2a - b = 5 - 2
3
second factor
a2+ab+b2=25+10+4a^2 + ab + b^2 = 25 + 10 + 4
39
53−23=3×39=1175^3 - 2^3 = 3 \times 39 = 117

5³ − 2³ = 3 × 39 = 117

Name it

Theorem 21.4.1 · Difference of Cubes

x3−y3=(x−y)(x2+xy+y2)x^3 - y^3 = (x - y)(x^2 + xy + y^2)

Theorem 21.4.2 · Sum of Cubes

x3+y3=(x+y)(x2−xy+y2)x^3 + y^3 = (x + y)(x^2 - xy + y^2)

Theorem 21.4.3 · Binomial Cube Expansions

(x+y)3=x3+3xy(x+y)+y3(x + y)^3 = x^3 + 3xy(x + y) + y^3
(x+y)3=x3+3x2y+3xy2+y3(x + y)^3 = x^3 + 3x^2y + 3xy^2 + y^3
(x−y)3=x3−3xy(x−y)−y3(x - y)^3 = x^3 - 3xy(x - y) - y^3
(x−y)3=x3−3x2y+3xy2−y3(x - y)^3 = x^3 - 3x^2y + 3xy^2 - y^3

Try it

Problem 21.5.12

AMC 8

How many perfect cubes lie between 28+12^8 + 1 and 218+12^{18} + 1, inclusive?

Problem 21.5.2

AMC 8

The positive integers xx and yy are the two smallest positive integers for which the product of 360 and xx is a square and the product of 360 and yy is a cube. What is the sum of xx and yy?

Contest cornerreal contest problems

Problem 21.5.13

AIME

There is a prime number pp such that 16p+116p + 1 is the cube of a positive integer. Find pp.

Checkpoint for section 21.4

Get 2 of 3 right to master this section. One try each, no hints.
1

Use the difference of cubes to compute 113−110\dfrac{11^3 - 1}{10}.

2

If x+y=5x + y = 5 and xy=6xy = 6, what is x3+y3x^3 + y^3?

3

What is the largest prime factor of 63+16^3 + 1?

21.5

Practice Problems

In this section you will be able to mix every trick from this chapter on contest problems.

Last stop: a mix of contest problems. Some need factoring, some need careful casework, and one needs a sneaky invariant. Every problem has three hints if you get stuck.

Want every problem from this chapter on one page? Open the problem set.

Contest cornerreal contest problems

Problem 21.5.4

AMC 8

For how many positive integer values of nn are both n3\frac{n}{3} and 3n3n three-digit whole numbers?

Problem 21.5.8

AMC 8

Suppose aa, bb, and cc are nonzero real numbers, and a+b+c=0a + b + c = 0. What are the possible value(s) for a∣a∣+b∣b∣+c∣c∣+abc∣abc∣\frac{a}{|a|} + \frac{b}{|b|} + \frac{c}{|c|} + \frac{abc}{|abc|}?

(A) 0 (B) 1 and −1-1 (C) 2 and −2-2 (D) 0, 2, and −2-2 (E) 0, 1, and −1-1

Problem 21.5.11

AMC 10

What is the greatest three-digit positive integer nn for which the sum of the first nn positive integers is not a divisor of the product of the first nn positive integers?

Problem 21.5.21(additional)

AMC 10

Which of the following is equivalent to x1−x−1x\sqrt{\dfrac{x}{1 - \frac{x-1}{x}}} when x<0x < 0?

(A) −x-x (B) xx (C) 11 (D) x2\sqrt{\frac{x}{2}} (E) x−1x\sqrt{-1}

Problem 21.5.23(additional)

AMC 10

Boris has an incredible coin-changing machine. When he puts in a quarter, it returns five nickels; when he puts in a nickel, it returns five pennies; and when he puts in a penny, it returns five quarters. Boris starts with just one penny. Which of the following amounts could Boris have after using the machine repeatedly?

(A) $3.63 (B) $5.13 (C) $6.30 (D) $7.45 (E) $9.07