Sub topic 3
Cyclicity: How Unit Digits Repeat in Powers
Prerequisites and the main idea
Assume you know place value, division with remainders, laws of exponents, and prime factorisation. A unit digit is the digit in the ones place. To find it, keep only the remainder after division by 10.
For example:
- \(347 \mod 10 = 7\), so 347 has unit digit 7.
- \(7^n\) and \(17^n\) always have the same unit digit because both bases leave remainder 7 when divided by 10.
Powers often repeat their unit digits in a cycle. Once you know the cycle, you only need a small remainder instead of calculating the full power.
The four basic cycle lengths
For a base ending in 0, 1, 5, or 6, the unit digit does not change.
| Last digit of base | Unit digits of successive powers | Cycle length |
|---|---|---|
| 0 | 0, 0, 0, ... | 1 |
| 1 | 1, 1, 1, ... | 1 |
| 4 | 4, 6, 4, 6, ... | 2 |
| 7 | 7, 9, 3, 1, ... | 4 |
The complete cycles for the nonconstant digits are:
| Last digit | Repeating cycle |
|---|---|
| 2 | 2, 4, 8, 6 |
| 3 | 3, 9, 7, 1 |
| 4 | 4, 6 |
| 7 | 7, 9, 3, 1 |
| 8 | 8, 4, 2, 6 |
| 9 | 9, 1 |
The exponent \(n\) starts at the first position of the cycle. Therefore, for \(n \geq 1\), use position
\[ (n-1)\bmod L, \]
where \(L\) is the cycle length.
A useful equivalent rule is to divide \(n\) by \(L\). If the remainder is nonzero, use that position. If the remainder is zero, use the last position in the cycle.
Worked example: a large power
Find the unit digit of \(7^{123}\).
- The base ends in 7.
- The cycle is \(7,9,3,1\), with length 4.
- Divide the exponent by 4:
\[ 123 \mod 4 = 3. \]
- Use the third cycle position: 3.
Therefore, the unit digit is 3.
The same method works for \(3^{2026}\). The cycle for 3 is \(3,9,7,1\), and
\[ 2026 \mod 4 = 2. \]
The second position is 9, so the unit digit is 9.
Checking with modular arithmetic
The notation \(a^n \mod 10\) means the remainder when \(a^n\) is divided by 10. Python can calculate this remainder efficiently with three-argument pow.
# Unit digit and last two digits are remainders mod 10 and mod 100.
print(pow(7, 123, 10)) # 3
print(pow(7, 2026, 100)) # 49Common errors
- Using \(n \mod L\) as a zero-based list index without handling remainder 0.
- Forgetting that the exponent position starts at 1, not 0.
- Repeating the full base instead of reducing it to its last digit.
- Calculating the enormous power directly instead of using its cycle.
- Applying a cycle rule to exponent 0 without checking it. For every nonzero base, \(a^0=1\).
Exercise
Find the unit digit of 8^57.
Show answer
The cycle for 8 is 8, 4, 2, 6. Since 57 mod 4 = 1, use the first position. The unit digit is 8.