Sub topic 7
Last Two Digits of Powers: Cycles and the 10k+1 Pattern
Prerequisites and the main idea
Assume you can divide with remainders, use laws of exponents, and work with prime factors. The last two digits of an integer are its remainder modulo 100. Thus, to find the last two digits of \(a^n\), compute \(a^n \pmod{100}\), without finding the full power.
Write a remainder from 0 to 99 with two places. For example, a remainder of 7 means the last two digits are 07. Every multiplication can be reduced modulo 100:
\[ (ab)\bmod 100 = [(a\bmod 100)(b\bmod 100)]\bmod 100. \]
So only the last two digits of intermediate results matter.
Cycles modulo 100
Powers often repeat modulo 100. For example, powers of 3 have this cycle:
| Exponent \(n\) | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
|---|---|---|---|---|---|---|---|---|---|---|
| \(3^n \bmod 100\) | 03 | 09 | 27 | 81 | 43 | 29 | 87 | 61 | 83 | 49 |
The sequence returns to 01 at \(n=20\), so the cycle length is 20. Therefore,
\[ 3^{2026}\equiv 3^{2026\bmod 20}=3^6\equiv 29\pmod {100}, \]
because \(2026\bmod20=6\). This reduction works directly when \(a\) is relatively prime to 100, meaning that \(a\) shares no factor with 100. Such a base has a repeating power cycle modulo 100. A safe general period for these bases is 20, although some bases have shorter cycles.
For instance, \(7^{123}\) uses position \(123\bmod20=3\). Since \(7^3=343\), its last two digits are 43.
# Python's pow(a, n, m) returns a^n modulo m.
print(f"{pow(7, 123, 100):02d}") # 43
print(f"{pow(7, 2026, 100):02d}") # 49When the base shares a factor with 100
Do not blindly reduce every exponent modulo 20. The rule is safest for \(\gcd(a,100)=1\). If \(a\) ends in 0, 2, 4, 5, 6, or 8, its powers may enter a shorter or eventually constant pattern.
Repeated squaring works for every base:
\[ a^{16}=((a^2)^2)^2. \]
At every stage, keep only the last two digits. To find \(a^{37}\), write \(37=32+4+1\), calculate \(a^{32}\), \(a^4\), and \(a\) modulo 100, then multiply those three remainders modulo 100.
The \(10k+1\) pattern
A number ending in 1 can often be written as \(10k+1\). For any positive integer \(n\),
\[ (10k+1)^n =1+n(10k)+\binom n2(10k)^2+\cdots. \]
Every term from the squared term onward contains \(100\), so it vanishes modulo 100:
\[ (10k+1)^n\equiv 1+10kn\pmod {100}. \]
Example:
\[ 21^{37}=(10\cdot2+1)^{37} \equiv1+10\cdot2\cdot37 =741\equiv41\pmod {100}. \]
This pattern is especially fast when the base ends in 1. It also handles very large exponents without building a cycle table.
A reliable CAT procedure
- Reduce the base modulo 100.
- Check whether the base is relatively prime to 100.
- Use a known cycle only when its length is justified. Otherwise use repeated squaring.
- Look for the special form \(10k+1\), which may be faster.
- Format a one-digit remainder with a leading zero.
A quick check is to compare the result modulo 10 with the known unit digit. For example, 41 must end in the same digit as the corresponding power modulo 10.
Exercise
Find the last two digits of \(41^{2025}\).
Show answer
Since \(41=10\cdot4+1\), use \(41^{2025}\equiv1+10\cdot4\cdot2025=81001\equiv01\pmod{100}\). The answer is 01.