Module 3.2 · Number Theory
Modular arithmetic
At the AMC 8 level, remainder problems are solved by spotting a repeating pattern. On the AMC 10 and 12 you need more power: congruence notation, division in modular arithmetic, Fermat's little theorem and Euler's theorem for huge exponents, and the Chinese remainder theorem for combining conditions. Together they turn "last two digits of " into a two-line calculation.
Congruences
Definition
Congruence
means divides , so and leave the same remainder when divided by .
Congruences behave like equations for addition, subtraction, multiplication and powers: if and , then , , and . So you can replace any number by anything congruent to it, at any point. Negative representatives are especially handy: , so .
Division needs care
You can't always divide. , but . Division by is allowed exactly when . In that case has an inverse: a number with , and "dividing by " means multiplying by .
To solve : since , the inverse of is . Multiply both sides by : .
Huge exponents
Fermat and Euler
Fermat's little theorem. If is prime and , then .
Euler's theorem. If , then , where counts the integers from to that are relatively prime to . For , .
So to reduce , reduce the exponent modulo (or modulo any smaller cycle length you find).
Why Fermat works: multiplying the nonzero residues by just rearranges them (no two products can be congruent, since you can cancel ). So the product of all of them is unchanged: , and cancelling gives . Euler's theorem is the same argument using only the residues relatively prime to .
Useful values: , . The actual cycle is often shorter. For instance , and .
The Chinese remainder theorem
If and are relatively prime, then any pair of conditions and has exactly one solution modulo . In practice, you list numbers that satisfy the condition with the largest modulus and test them against the others. The theorem also works in reverse: to find something modulo , find it modulo and modulo separately and combine.
Worked example: Fermat's little theorem
What is the remainder when is divided by ?
By Fermat, . Since , . The remainder is .
Worked example: Last two digits
What are the last two digits of ?
and . Since , . The last two digits are .
Worked example: Chinese remainder theorem
What is the smallest positive integer that leaves remainder when divided by , remainder when divided by , and remainder when divided by ?
Numbers that are : Of these, and are . Then fails and works. The answer is , and every solution is .
Worked example: A tower of exponents
What are the last two digits of ?
Since , you need the exponent modulo . Because , . So . The last two digits are .
Common mistake
Exponents are reduced modulo the cycle length (like or ), never modulo itself. is not ; since , . And Fermat needs : , not .
Tip
When the modulus is not prime and the base shares a factor with it (like ), Euler's theorem doesn't apply directly. Split the modulus with the Chinese remainder theorem: the power is , and Euler works modulo .
Practice
What is the remainder when is divided by ?
For how many integers with is divisible by ?
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
What is the remainder when is divided by ?
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
What is the remainder when is divided by ?
What are the last two digits of ? (Enter them as a number.)
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
How many integers with leave remainder when divided by , remainder when divided by , and remainder when divided by ?
What is the largest integer that divides for every integer ?
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
What is the remainder when is divided by ?
What are the last two digits of ? (Enter them as a number.)
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
Real contest practice
- 2017 AMC 10B, Problem 14: Fermat's little theorem modulo , dressed as a probability question.
- 2010 AMC 12A, Problem 23: the last two nonzero digits of , using inverses and the Chinese remainder theorem.