Module 3.3 · Number Theory
Linear Diophantine equations
A Diophantine equation is an equation where only integer solutions count. The linear ones, , show up on the AMC as ticket sales, coin and stamp problems, and "how many ways" questions. You need three skills: decide whether there are any solutions, write down all of them, and count the ones that fit the constraints (usually positive or nonnegative).
When are there solutions?
Whatever integers and you pick, is a multiple of . So if there are no solutions. The converse is also true (it follows from the Euclidean algorithm, in the next module): has integer solutions exactly when divides . For example, has none, because every value of is a multiple of .
All solutions from one
Suppose and is one solution. If is another, subtracting gives . Since and share no factor, must divide . That forces the following.
General solution
If and is one solution of , then every solution is
Solutions step by in and by in (in opposite directions). If , divide the whole equation by first.
To find one solution, use congruences: forces . Solve for modulo , then compute .
Counting solutions with constraints
Once you have the general solution, the constraints (or ) and become two inequalities on , and you count the integers in between. Often it's quicker to say " must be " and list the values of directly.
The Chicken McNugget theorem
Which amounts can you make from -cent and -cent coins, using nonnegative numbers of each?
Chicken McNugget theorem
If and are relatively prime positive integers, the largest integer that cannot be written as with is
and exactly positive integers cannot be written that way.
Why: every integer has exactly one representation with . It uses nonnegative coins exactly when that . The worst case is and , which gives . Every larger has . For the count, and can't both be representable (they would add to ) and one of them always is, so exactly half of fail.
With three or more coin values there is no formula. List which residues you can reach modulo the smallest coin, and the smallest amount reaching each.
Worked example: Finding every solution
Find all positive integer solutions of .
Mod : , that is . Try : . So . With , and .
The general solution is , . For you need ; for you need . So and the only positive solution is .
Worked example: Counting nonnegative solutions
How many ordered pairs of nonnegative integers satisfy ?
Mod : , so and . Also , so . The values each give a nonnegative integer . There are solutions.
Worked example: Coins that can't make change
Coins come in -cent and -cent values. What is the largest amount you can't pay exactly, and how many positive amounts can't be paid?
, so the largest impossible amount is cents, and the number of impossible positive amounts is .
Worked example: A three-variable count
In how many ways can you make cents from pennies, -cent coins and nickels?
You need nonnegative . Fix and count solutions of , which has solutions:
| solutions | ||
|---|---|---|
The total is .
Common mistake
Read the constraints carefully. "Positive" means ; "nonnegative" allows . The Chicken McNugget formula is for nonnegative combinations. If both kinds of coin must be used at least once, the amounts shift up by .
Practice
Which of the following equations has no solution in integers and ?
How many ordered pairs of positive integers satisfy ?
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
Using only -point and -point scoring plays, what is the largest score a team can not reach?
A theater sold adult tickets for $11 each and child tickets for $7 each, taking in exactly $200. At least one of each kind was sold. What is the greatest possible total number of tickets sold?
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
How many positive integers can not be written in the form with and nonnegative integers?
Stamps come in -cent and -cent values. In how many ways (counting only how many of each stamp you use) can you make exactly $10.00 of postage?
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
A snack bar sells boxes of , and nuggets. How many positive whole numbers of nuggets can not be bought exactly?
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
Real contest practice
- 2023 AMC 12B, Problem 16: the largest price that can't be paid with three coin values.
- 2019 AIME II, Problem 14: a harder stamp problem built on the Chicken McNugget theorem (a stretch beyond the AMC).