Sub topic 1
The Last Digits of a Number Are Its Remainders mod 10 and mod 100
Questions such as "What is the unit digit of 7^123?" or "What are the last two digits of 2015 × 1987?" look like questions about digits. They are remainder questions. Once you see that, every later technique in this tutorial (cycles, the 10k+1 pattern, trailing zeros) is a way of computing a remainder without computing the whole number.
Prerequisites
This chapter assumes you are comfortable with the following:
- Place value and arithmetic with large numbers.
- Division with remainders: for integers n and m > 0, n = m·q + r with 0 ≤ r < m.
- The laws of exponents.
- Prime factorisation of integers.
- The idea of a factorial, n!.
Prime factorisation and factorials matter in later chapters, not here. You do not need any prior knowledge of modular arithmetic. The chapter introduces what it uses.
The core idea
Write a number in place value. For 4,827:
4827 = 4·1000 + 8·100 + 2·10 + 7
The terms 4·1000, 8·100 and 2·10 are all multiples of 10. So 4827 = 10·482 + 7, and dividing by 10 leaves quotient 482 and remainder 7. The unit digit is the remainder on division by 10.
The same argument works one step further. The terms 4·1000 and 8·100 are multiples of 100. So 4827 = 100·48 + 27, and the remainder on division by 100 is 27. These are the last two digits.
- The unit digit of n is n mod 10.
- The last two digits of n are n mod 100.
Here "n mod m" means the remainder of n on division by m, a number from 0 to m − 1.
| Number | n mod 10 | n mod 100 |
|---|---|---|
| 4827 | 7 | 27 |
| 90 | 0 | 90 |
| 2005 | 5 | 05 |
| 100 | 0 | 00 |
The general reason is that 10^k is a multiple of 10 for every k ≥ 1, and a multiple of 100 for every k ≥ 2. Everything to the left of the last digit (or last two digits) is a multiple of the modulus and drops out of the remainder.
Congruence: the working model
Two integers a and b are congruent mod m, written a ≡ b (mod m), if m divides a − b. Equivalently, they leave the same remainder on division by m. So 4827 ≡ 7 (mod 10) and 4827 ≡ 27 (mod 100).
The key property is that sums, differences and products can be computed on remainders alone.
| Operation | Rule | Example (mod 10) |
|---|---|---|
| Sum | (a + b) mod m = ((a mod m) + (b mod m)) mod m | (38 + 47) → (8 + 7) = 15 → 5 |
| Difference | (a − b) mod m = ((a mod m) − (b mod m)) mod m | (83 − 47) → (3 − 7) = −4 → 6 |
| Product | (a · b) mod m = ((a mod m) · (b mod m)) mod m | (38 · 47) → (8 · 7) = 56 → 6 |
Check the last row: 38 × 47 = 1786, which ends in 6. The reason this works is that if a = m·p + r and b = m·q + s, then a·b = m·(…) + r·s. Every other term has a factor of m.
The same rules hold for powers, because a power is repeated multiplication: reducing the base first is always allowed. For example, 13² ≡ 3² = 9 (mod 10), and 13² = 169.
A worked example
Find the unit digit and the last two digits of 237 × 489.
For the unit digit, reduce each factor mod 10 and multiply: 7 × 9 = 63, and 63 mod 10 = 3.
For the last two digits, reduce each factor mod 100 and multiply: 37 × 89 = 3293, and 3293 mod 100 = 93.
Direct check: 237 × 489 = 237 × 500 − 237 × 11 = 118,500 − 2,607 = 115,893. It ends in 3 and in 93.
Notice what you did not do. You never wrote the full product, and the intermediate numbers stayed small. This saves time on CAT when the factors have four or five digits, or when the expression has several terms.
The procedure
The same four steps apply to every question in this chapter.
Here is a multi-term example. Find the unit digit of 17 × 23 + 38 × 46.
- 17 × 23 ≡ 7 × 3 = 21 ≡ 1 (mod 10).
- 38 × 46 ≡ 8 × 6 = 48 ≡ 8 (mod 10).
- 1 + 8 = 9.
Check: 391 + 1748 = 2139, which ends in 9.
Subtraction and negative remainders
A remainder must lie between 0 and m − 1. When a subtraction on remainders goes negative, add m (once, or more if needed) until it is in range.
Find the last two digits of 4003 − 1987.
- 4003 mod 100 = 03 and 1987 mod 100 = 87.
- 3 − 87 = −84.
- −84 + 100 = 16.
Check: 4003 − 1987 = 2016, which ends in 16. The unit digit works the same way: 3 − 7 = −4, and −4 + 10 = 6. It matches the 6 in 2016.
This is the same as borrowing in ordinary subtraction. The negative remainder is what the borrow hides.
Checking with Python
Python's % operator returns a result between 0 and m − 1 for positive m, even when the left side is negative. This makes it a convenient checker. In C and Java, % can return a negative value, so do not assume the same behaviour there.
a, b = 237, 489
# Reduce first, then multiply, then reduce again.
print((a * b) % 10, ((a % 10) * (b % 10)) % 10) # 3 3
print((a * b) % 100, ((a % 100) * (b % 100)) % 100) # 93 93
# Negative intermediate results come back into range.
print((3 - 87) % 100) # 16
# Last two digits as a zero-padded string.
def last_two(n):
return f"{n % 100:02d}"
print(last_two(2005)) # 05
print(last_two(100)) # 00Python's three-argument pow computes a power modulo m directly. Use it to check a hand answer.
# Unit digit and last two digits are remainders mod 10 and mod 100.
print(pow(7, 123, 10)) # 3
print(pow(7, 2026, 100)) # 49You cannot use pow in the exam, and you do not yet know how to get these two answers by hand. The next chapters supply the methods. For now, the point is that both questions are plain remainder questions.
What else the last digits tell you
Because 10 = 2 × 5 and 100 = 4 × 25, the last digit or last two digits also fix some other remainders.
- The last digit alone gives the remainder mod 2 and mod 5. For example, 4827 ends in 7, which is odd and leaves remainder 2 on division by 5.
- The last two digits alone give the remainder mod 4, mod 20, mod 25 and mod 50. For example, 4827 ≡ 27 (mod 100), so 4827 leaves remainder 3 on division by 4 (27 = 4·6 + 3) and remainder 2 on division by 25 (27 = 25 + 2).
This is the reason for the familiar divisibility tests for 2, 4, 5 and 25. A later chapter uses the 4 and 25 split to find last two digits of large powers.
Common errors
- Using the wrong modulus. For the last two digits, multiplying only the unit digits is wrong. 237 × 489 has unit digit 3, but its last two digits are 93, not 63 (7 × 9) and not 03. Reduce mod 100 when two digits are asked.
- Leaving a negative remainder. An answer of −84 for "last two digits" must become 16. Add the modulus.
- Dropping the leading zero. The last two digits of 2005 are 05. An answer written as 5 may not match the option "05", and in a sum such as 2005 + 1998 the zero matters. (5 + 98 = 103, so the last two digits are 03.)
- Reducing the exponent mod 10. Reducing the base is allowed, but you cannot reduce the exponent by the same modulus. 3^12 is not congruent to 3² mod 10: 3^12 = 531,441 ends in 1, while 3² = 9. Exponents follow a different rule, which the cyclicity chapter develops.
- Dividing remainders. Addition, subtraction and multiplication carry over to remainders. Division does not. For example, 6 × 5 and 2 × 5 both leave remainder 0 mod 10, but 6 and 2 are not congruent mod 10. If a question involves a quotient, compute the quotient first, or work with a modulus that suits it.
- Carrying digits that do not matter. If you only need mod 100, the hundreds digit and above cannot change the answer. Cross them out early.
Exercises
Exercise
Find the unit digit of 1457 × 2383 + 6919 × 874.
Show answer
Reduce mod 10: 7 × 3 = 21 → 1, and 9 × 4 = 36 → 6. The sum is 1 + 6 = 7. Check: the products are 3,472,031 and 6,047,206, and their sum is 9,519,237, which ends in 7.
Exercise
Find the last two digits of 2015 × 1987 − 3004.
Show answer
Mod 100: 15 × 87 = 1305 → 05, and 3004 → 04. Then 05 − 04 = 01, so the last two digits are 01. Check: 2015 × 1987 = 4,003,805, and 4,003,805 − 3004 = 4,000,801.
Exercise
A student says 3^12 has the same unit digit as 3^2, because 12 ≡ 2 (mod 10). Is the claim true? What does the example show about reducing exponents?
Show answer
The claim is false. 3^2 = 9, but 3^12 = 531,441 ends in 1. The base may be reduced mod 10, but the exponent may not be reduced by the same modulus. Exponents obey a separate rule based on the repeating cycle of unit digits.