Sub topic 1
The last digits of a number are its remainders mod 10 and mod 100
Prerequisites
This chapter assumes you know:
- Place value and basic arithmetic with large numbers
- Division with remainders
- Laws of exponents, such as a^m × a^n = a^(m+n) and (a^m)^n = a^(mn)
Last digits as remainders
The unit digit of a number is its remainder when divided by 10. The last two digits form its remainder when divided by 100. For example, 2026 mod 10 is 6, and 2026 mod 100 is 26.
Because of this, a question about the last digit is a remainder question. You can compute it without finding the full number.
Unit digits of sums, differences and products
Only the unit digits of the operands affect the unit digit of the result.
- Sum: 17 + 28 has unit digits 7 and 8. Their sum is 15, so the unit digit is 5.
- Product: 37 × 44 has unit digits 7 and 4. Their product is 28, so the unit digit is 8.
- Difference: 53 − 27 has unit digits 3 and 7. The result is −4, which is 6 mod 10. The actual answer is 26, so the unit digit is 6.
Cyclicity: how unit digits repeat in powers
The unit digit of a^n repeats in a cycle as n grows. The table lists each cycle.
| Unit digit of base | Cycle of unit digits | Cycle length |
|---|---|---|
| 0, 1, 5, 6 | stays the same | 1 |
| 4, 9 | 4,6 or 9,1 | 2 |
| 2, 3, 7, 8 | 2,4,8,6 or 3,9,7,1 or 7,9,3,1 or 8,4,2,6 | 4 |
Why the cycle works
Each unit digit depends only on the previous one, since multiplying by the base changes only the unit digit. Once a digit repeats, the sequence repeats forever.
Unit digit of a large power in three steps
To find the unit digit of a^n:
- Take the unit digit of the base a.
- Find its cycle length from the table.
- Compute n mod (cycle length). If the remainder is 0, use the last position in the cycle.
# pow(base, exp, mod) computes the remainder directly.
print(pow(7, 123, 10)) # 3
print(pow(2, 2026, 10)) # 4Worked example: find the unit digit of 2^2026. The cycle of 2 is 2, 4, 8, 6, with length 4. Since 2026 mod 4 = 2, the answer is the second position, which is 4.
Exercise
What is the unit digit of 9^53?
Show answer
The cycle of 9 is 9, 1, with length 2. Since 53 mod 2 = 1, the answer is the first position, which is 9.