Modular Arithmetic
Remainders, congruences, last digits, cyclicity, Chinese-remainder style reasoning
What you need to know
- What "mod" means. means and leave the same remainder when divided by ; in other words, divides . Example: , since divides .
- Working with remainders. You can add, subtract, and multiply congruences, swapping any number for its remainder. You may divide both sides by only when shares no factor with . Example: . But while : dividing by failed.
- Units digits cycle. The units digits of repeat with a cycle length that divides . Example: powers of end in ; since , ends in .
- Any modulus. The remainders of mod always start repeating at some point, so once inside the cycle, reduce the exponent by the cycle length. A few powers may come before the cycle starts. Example: mod , powers of go ; the cycle starts at .
- Fermat's Little Theorem. If is prime and does not divide , then .
- Squares. A square leaves remainder or when divided by or by . Divided by , a square leaves , , or , and an odd square always leaves . Example: and .
- Chinese Remainder Theorem. If , a number's remainders mod and mod pin down its remainder mod . Example: remainder mod and mod means remainder mod .
- Digit shortcuts. A number and its digit sum agree mod . Mod , use the alternating digit sum, starting with on the units digit. Mod , keep the last two digits. Example: leaves mod (digit sum ), mod (), and mod .
How AMC 10 tests it
- "What is the units digit (or remainder mod ) of ?" Find the cycle and reduce the exponent (problems 8–15).
- Day-of-week or clock problems: count days, reduce mod or , watch leap years.
- "Find the smallest with , , ": the Chinese Remainder Theorem, by listing or stepping through multiples (problems 12–20).
- Showing an equation has no solutions by working mod , , , or .
- Divisibility in disguise, such as "the average was a whole number after each entry," which means the first entries add up to a multiple of .
Standard approaches
- Reduce the base first, find the cycle length of its powers, and reduce the exponent by that length (never by ).
- In sums of factorials or products, every term past some point is , so only the first few matter. Example: from on, factorials end in , so ends in the same digit as .
- For several congruences, start with the largest modulus and step through its numbers until the others hold. Example: above, gives , and already works.
- For "no integer solutions," use a modulus where squares or cubes have few remainders. Example: leaves , , or mod , so it never equals .
- Use negative remainders to make powers easy: , so .
Worked example
What is the remainder when is divided by ?
(A) (B) (C) (D) (E)
Step 1: the cycle. Multiply by and keep the remainder mod each time: , , , , , . The pattern repeats every powers.
Step 2: place . , so .
Step 3: add. , so . Then .
The answer is .
Pitfalls
- Reducing the exponent by instead of the cycle length. Example: using gives , which is wrong.
- Misplacing remainder : it means the end of the cycle. Example: , so is the th entry, , not the first entry, . Likewise ends in , the last of , not in .
- Dividing both sides by a number that shares a factor with the modulus (see the example above).
- Off-by-one errors in calendar problems: counting the starting day, or February in leap years. Example: days after a Monday is a Thursday (), not a Wednesday.
Traps that recur
- Assuming the bits repeat 111 or 011 from the first few (x₀ = x₁ = x₂ = 1) without computing far enough to see the period-3 pattern 0,1,1. (2022 AMC 10B #25)
- Reducing 90! mod 100 directly (it is 0) or forgetting that removing 21 factors of 5 also requires removing exactly 21 factors of 2. (2010 AMC 10A #24)
- Assuming powers spread out over many residues (answering 25 or 125) instead of testing whether 100 is a multiple of the order of every unit mod 125. (2024 AMC 10B #18)
- Testing only whether each fraction is an integer separately; for odd m none of them is, yet the fractional parts 1/2 + 1/4 + 1/8 + 1/8 add up to exactly 1. (2024 AMC 10B #24)
- 1.2010 AMC 10B #18
Positive integers , , and are randomly and independently selected with replacement from the set . What is the probability that is divisible by ?
- A)
- B)
- C)
- D)
- E)
- 2.2009 AMC 10B #21
What is the remainder when is divided by 8?
- A)
- B)
- C)
- D)
- E)
- 3.2006 AMC 10A #20
Six distinct positive integers are randomly chosen between and , inclusive. What is the probability that some pair of these integers has a difference that is a multiple of ?
- A)
- B)
- C)
- D)
- E)
- 4.2004 AMC 10B #13
In the United States, coins have the following thicknesses: penny, mm; nickel, mm; dime, mm; quarter, mm. If a stack of these coins is exactly mm high, how many coins are in the stack?
- A)
- B)
- C)
- D)
- E)
- 5.2000 AMC 10 #14
Mrs. Walter gave an exam in a mathematics class of five students. She entered the scores in random order into a spreadsheet, which recalculated the class average after each score was entered. Mrs. Walter noticed that after each score was entered, the average was always an integer. The scores (listed in ascending order) were , , , , and . What was the last score Mrs. Walters entered?
- A)
- B)
- C)
- D)
- E)
- 6.2000 AMC 10 #17
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
- 7.2024 AMC 10B #24
Let How many of the values , , , and are integers?
- A)
- B)
- C)
- D)
- E)
- 8.2024 AMC 10B #18
How many different remainders can result when the th power of an integer is divided by ?
- A)
- B)
- C)
- D)
- E)
- 9.2022 AMC 10A #19
Define as the least common multiple of all the integers from to inclusive. There is a unique integer such that What is the remainder when is divided by ?
- A)
- B)
- C)
- D)
- E)
- 10.2021 AMC Fall 10B #22
For each integer , let be the sum of all products , where and are integers and . What is the sum of the 10 least values of such that is divisible by ?
- A)
- B)
- C)
- D)
- E)
- 11.2017 AMC 10B #23
Let be the -digit number that is formed by writing the integers from to in order, one after the other. What is the remainder when is divided by ?
- A)
- B)
- C)
- D)
- E)
- 12.2017 AMC 10B #25
Last year Isabella took math tests and received different scores, each an integer between and , inclusive. After each test she noticed that the average of her test scores was an integer. Her score on the seventh test was . What was her score on the sixth test?
- A)
- B)
- C)
- D)
- E)
- 13.2011 AMC 10B #23
What is the hundreds digit of ?
- A)
- B)
- C)
- D)
- E)
- 14.2008 AMC 10A #24
Let . What is the units digit of ?
- A)
- B)
- C)
- D)
- E)
- 15.2003 AMC 10A #25
Let be a -digit number, and let and be the quotient and the remainder, respectively, when is divided by . For how many values of is divisible by ?
- A)
- B)
- C)
- D)
- E)
- 16.2003 AMC 10B #25
How many distinct four-digit numbers are divisible by and have as their last two digits?
- A)
- B)
- C)
- D)
- E)
- 17.2022 AMC 10B #25
Let be a sequence of numbers, where each is either or . For each positive integer , define Suppose for all . What is the value of the sum
- A)
- B)
- C)
- D)
- E)
- 18.2010 AMC 10A #24
The number obtained from the last two nonzero digits of is equal to . What is ?
- A)
- B)
- C)
- D)
- E)
Answers
| # | Answer | The idea it turns on |
|---|---|---|
| 1 | E | Factor the expression as a times (bc + b + 1). It is a multiple of 3 when a is, or when bc + b + 1 is. |
| 2 | D | Divided by 8, powers of 3 leave remainders 1, 3, 1, 3, and so on. Each pair adds to 4, and there are 1005 pairs. |
| 3 | E | Two numbers differ by a multiple of 5 exactly when they leave the same remainder when divided by 5. Six numbers but only five remainders, so it always happens. |
| 4 | B | In hundredths of a millimeter, every coin is 15 more than a multiple of 20. So the coin count must be a multiple of 4: 8. |
| 5 | C | A whole-number average means the first k scores add to a multiple of k. Work backward from the total 400, using multiples of 4 and then multiples of 3. |
| 6 | D | Trading a quarter or a nickel keeps the money the same. Trading a penny adds exactly 124 cents. So any total is 1 cent more than a multiple of 124. |
| 7 | E | Put everything over 8. For even m each top term is a multiple of 8. For odd m the top becomes 4(m + 1), a multiple of 8. |
| 8 | B | Multiples of 5 give remainder 0. Any other number to the 100th power is 1 more than a multiple of 125, built up one factor of 5 at a time. |
| 9 | C | Multiply through by L17. Then h is L17/1 + L17/2 + ... + L17/17, and every term except the last is a multiple of 17. |
| 10 | B | Squaring 1 + 2 + ... + n gives each product twice, leading to a formula with 24 on the bottom. So the top needs a factor of 9. |
| 11 | C | Split 45 into 5 and 9. N ends in 4, so its remainder by 5 is 4; its digit sum matches 1 through 44 added up, 990. |
| 12 | E | Subtract 90 from each score. The 7-test total is a multiple of 7 from 28 to 49, and minus 5 it must be a multiple of 6: only 35. |
| 13 | D | Only the last three digits matter, and they match those of 11 to the 2011th power. For 11 to the n, they come from 1 + 10n + 50n(n-1). |
| 14 | D | k and its square end in 0. Powers of 2 end in 2, 4, 8, 6 repeating. Since k is a multiple of 4, 2^k ends in 6. |
| 15 | B | Write n as 99 times q plus the sum q + r. Since 11 divides 99, q + r is a multiple of 11 exactly when n is. |
| 16 | B | The 90 numbers 1023, 1123, ..., 9923 go up by 100. Each step changes the remainder after dividing by 3, so every third number works. |
| 17 | A | Write the first few S_n in binary. After the first 1 the bits repeat 1, 1, 0, so bits at multiples of 3 are 0. |
| 18 | A | Remove the 21 fives and 21 twos that make the zeros, then track only the remainder after dividing by 25. Runs of four non-multiples of 5 act like -1. |
Problems © Mathematical Association of America (MAA), American Mathematics Competitions. Reproduced for non-commercial educational use. The topic note, tags and key insights are original to this site.