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.2023 AMC 10B #8
What is the units digit of ?
- A)
- B)
- C)
- D)
- E)
- 2.2012 AMC 10B #4
When Ringo places his marbles into bags with 6 marbles per bag, he has 4 marbles left over. When Paul does the same with his marbles, he has 3 marbles left over. Ringo and Paul pool their marbles and place them into as many bags as possible, with 6 marbles per bag. How many marbles will be left over?
- A)
- B)
- C)
- D)
- E)
- 3.2025 AMC 10B #2
Jerry wrote down the ones digit of each of the first positive squares: . What is the sum of all the numbers Jerry wrote down?
- A)
- B)
- C)
- D)
- E)
- 4.2024 AMC 10B #7
What is the remainder when is divided by ?
- A)
- B)
- C)
- D)
- E)
- 5.2023 AMC 10B #6
Let , , and for . How many terms in the sequence are even?
- A)
- B)
- C)
- D)
- E)
- 6.2021 AMC Fall 10A #12
The base-nine representation of the number is What is the remainder when is divided by
- A)
- B)
- C)
- D)
- E)
- 7.2017 AMC 10A #13
Define a sequence recursively by and the remainder when is divided by for all Thus the sequence starts What is
- A)
- B)
- C)
- D)
- E)
- 8.2016 AMC 10B #8
What is the tens digit of
- A)
- B)
- C)
- D)
- E)
- 9.2015 AMC 10B #10
What is the sign and units digit of the product of all the odd negative integers strictly greater than ?
- A)
- B)
- C)
- D)
- E)
- 10.2009 AMC 10B #13
As shown below, convex pentagon has sides , , , , and . The pentagon is originally positioned in the plane with vertex at the origin and vertex on the positive -axis. The pentagon is then rolled clockwise to the right along the -axis. Which side will touch the point on the -axis?

- A)
- B)
- C)
- D)
- E)
- 11.2007 AMC 10B #9
A cryptographic code is designed as follows. The first time a letter appears in a given message it is replaced by the letter that is place to its right in the alphabet (asumming that the letter is one place to the right of the letter ). The second time this same letter appears in the given message, it is replaced by the letter that is places to the right, the third time it is replaced by the letter that is places to the right, and so on. For example, with this code the word "banana" becomes "cbodqg". What letter will replace the last letter in the message
- A)
- B)
- C)
- D)
- E)
- 12.2006 AMC 10B #11
What is the tens digit in the sum
- A)
- B)
- C)
- D)
- E)
- 13.2003 AMC 10A #16
What is the units digit of ?
- A)
- B)
- C)
- D)
- E)
- 14.2000 AMC 10 #6
The Fibonacci sequence starts with two 1s, and each term afterwards is the sum of its two predecessors. Which one of the ten digits is the last to appear in the units position of a number in the Fibonacci sequence?
- A)
- B)
- C)
- D)
- E)
- 15.2022 AMC 10B #17
One of the following numbers is not divisible by any prime number less than Which is it?
- A)
- B)
- C)
- D)
- E)
- 16.2020 AMC 10B #15
Steve wrote the digits , , , , and in order repeatedly from left to right, forming a list of digits, beginning He then erased every third digit from his list (that is, the rd, th, th, digits from the left), then erased every fourth digit from the resulting list (that is, the th, th, th, digits from the left in what remained), and then erased every fifth digit from what remained at that point. What is the sum of the three digits that were then in the positions ?
- A)
- B)
- C)
- D)
- E)
- 17.2018 AMC 10B #16
Let be a strictly increasing sequence of positive integers such that What is the remainder when is divided by ?
- A)
- B)
- C)
- D)
- E)
- 18.2018 AMC 10B #13
How many of the first numbers in the sequence are divisible by ?
- A)
- B)
- C)
- D)
- E)
- 19.2018 AMC 10A #19
A number is randomly selected from the set , and a number is randomly selected from . What is the probability that has a units digit of ?
- A)
- B)
- C)
- D)
- E)
- 20.2017 AMC 10B #14
An integer is selected at random in the range . What is the probability that the remainder when is divided by is ?
- A)
- B)
- C)
- D)
- E)
- 21.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)
- 22.2009 AMC 10B #21
What is the remainder when is divided by 8?
- A)
- B)
- C)
- D)
- E)
- 23.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)
- 24.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)
- 25.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)
- 26.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
- 27.2024 AMC 10B #24
Let How many of the values , , , and are integers?
- A)
- B)
- C)
- D)
- E)
- 28.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)
- 29.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)
- 30.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)
- 31.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)
- 32.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)
- 33.2011 AMC 10B #23
What is the hundreds digit of ?
- A)
- B)
- C)
- D)
- E)
- 34.2008 AMC 10A #24
Let . What is the units digit of ?
- A)
- B)
- C)
- D)
- E)
- 35.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)
- 36.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)
- 37.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)
- 38.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 | A | Only the last digit of each base matters. Last digits of powers of 2 and of 3 repeat every 4 steps, so use the remainders of 2023 and 2022. |
| 2 | A | Put the two leftover piles together: 4 + 3 = 7 marbles. Seven marbles fill one more bag of 6, leaving 1. |
| 3 | D | The last digit of a square depends only on the last digit of the number, so the list repeats every ten terms, and each block of ten adds to 45. |
| 4 | A | Pull out the common factor 7 to the power 2024. What is left is 1 + 7 + 49 = 57, which is 3 times 19. |
| 5 | E | Look only at odd or even. The terms go odd, odd, even, and that pattern repeats, so a term is even exactly when its position is a multiple of 3. |
| 6 | D | Powers of 9 leave remainders 1, 4, 1, 4, ... when divided by 5. Multiply each nonzero digit by the remainder for its place and add. |
| 7 | D | The list repeats every 8 terms, so any 8 terms in a row make one full cycle, which adds up to 9. |
| 8 | A | Only the last two digits matter. 2015 squared ends in 25, higher powers keep ending in 25, and 25 - 17 = 8, so the number ends in 08. |
| 9 | C | There are 1007 negative numbers, an odd count, so the product is negative. All the numbers are odd and one of them is -5, so the product ends in 5. |
| 10 | C | Rolling lays the sides down in order AB, BC, CD, DE, EA, repeating every 23 units. 2009 leaves remainder 8 when divided by 23, landing on CD. |
| 11 | D | The last s is the 12th s, so it moves 1 + 2 + ... + 12 = 78 places, exactly three trips around the alphabet. |
| 12 | C | Every factorial from 10! onward ends in 00, so it cannot change the tens digit. Only 7! + 8! + 9! matters. |
| 13 | C | Only the last digit matters, so look at powers of 3. Their last digits repeat 3, 9, 7, 1, and 2003 is 3 past a multiple of 4. |
| 14 | C | Only the last digits matter. Build the list of last digits by adding the previous two and keeping the ones digit, and check off each digit when it first appears. |
| 15 | C | Knock out four choices with quick remainder checks: (A) and (D) are multiples of 3, (B) and (E) end in 5. Only 2^607 − 1 is left. |
| 16 | D | Work with blocks of 30 digits: erasing leaves 20, then 15, then 12. So the final list repeats every 12 digits. |
| 17 | E | A number and its cube always leave the same remainder when divided by 6, so the sum of cubes acts like the plain sum. |
| 18 | C | The terms are 1 followed by zeros and a 1. Every fourth term, starting with 101 itself, is a multiple of 101, so count 1st, 5th, 9th, and so on. |
| 19 | E | Only the last digit of m matters: 1 always works, 5 never, 9 needs an even exponent, 3 and 7 need a multiple of 4. |
| 20 | D | The fourth powers of 1, 2, 3, 4 all leave remainder 1 when divided by 5. So N to the 16th leaves 1 unless N is a multiple of 5. |
| 21 | 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. |
| 22 | 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. |
| 23 | 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. |
| 24 | 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. |
| 25 | 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. |
| 26 | 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. |
| 27 | 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. |
| 28 | 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. |
| 29 | 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. |
| 30 | 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. |
| 31 | 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. |
| 32 | 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. |
| 33 | 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). |
| 34 | 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. |
| 35 | 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. |
| 36 | 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. |
| 37 | 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. |
| 38 | 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.