Sub topic 8
Splitting mod 100 into mod 4 and mod 25
This chapter assumes you can find remainders, know that "last two digits" means the remainder mod 100, and have seen unit-digit cycles. It adds one more method for last-two-digit questions. You split the problem into two easier remainder problems and then join the answers.
Why split 100 at all
The number 100 factors as 4 × 25, and 4 and 25 share no common factor. Because of that, a remainder mod 100 is fixed by two smaller remainders:
- the remainder mod 4
- the remainder mod 25
Among the numbers 0 to 99, no two have the same pair (remainder mod 4, remainder mod 25). So if you know both remainders, you know the last two digits. This is a special case of the Chinese Remainder Theorem (CRT).
The two pieces are easier than the whole:
- Mod 4 depends only on whether the base is even, and on its remainder mod 4. Most cases settle in one line.
- Mod 25 has a cycle that divides 20 for any base not divisible by 5. You reduce the exponent mod 20 instead of searching for a cycle of length 20, 10, 5 or 4 mod 100.
Step 1: the mod 4 remainder
Use these rules for a^n with n ≥ 2. They cover most questions.
| Base a | a^n mod 4 |
|---|---|
| even | 0 (since 4 divides a^2) |
| a ≡ 1 (mod 4) | 1 |
| a ≡ 3 (mod 4) | 1 if n is even, 3 if n is odd |
The last row works because 3 ≡ −1 (mod 4), and (−1)^n is 1 for even n and −1 for odd n. A remainder of −1 is the same as 3.
To find a mod 4 quickly, look at the last two digits of a. For 2026, 26 = 24 + 2, so 2026 ≡ 2 (mod 4).
Step 2: the mod 25 remainder
Split into two cases.
- a is a multiple of 5 and n ≥ 2. Then a^n is divisible by 25, so the remainder is 0.
- a is not a multiple of 5. Then a^20 ≡ 1 (mod 25). This follows from Euler's theorem, because exactly 20 of the numbers 1 to 25 are coprime to 25. You only need the exponent mod 20. Many bases cycle faster. For example, 7^2 = 49 ≡ −1 (mod 25), so 7^4 ≡ 1.
When you hunt for a short cycle, rewrite a nearby number as ±1 or ±(a small number). Writing 49 ≡ −1 is the same trick you use in the 10k+1 pattern.
Step 3: combine the two remainders
Suppose a^n ≡ r4 (mod 4) and a^n ≡ r25 (mod 25). The candidates for the last two digits are
r25, r25 + 25, r25 + 50, r25 + 75.
These are the only numbers in 0 to 99 with remainder r25 mod 25. Since 25 ≡ 1 (mod 4), each step of +25 raises the mod 4 remainder by 1. Their mod 4 remainders therefore cycle through all four values, and exactly one candidate matches r4. Check the candidates in order and stop at the match.
Worked example 1: the last two digits of 7^2026
- Mod 4. 7 ≡ 3 ≡ −1, and 2026 is even, so 7^2026 ≡ 1.
- Mod 25. 7^2 = 49 ≡ −1, so 7^4 ≡ 1. Then 2026 = 4 × 506 + 2, so 7^2026 ≡ 7^2 ≡ 49 ≡ 24.
- Combine. The candidates are 24, 49, 74, 99. Their remainders mod 4 are 0, 1, 2, 3. We need 1, so the answer is 49.
The answer is 49.
Worked example 2: the last two digits of 2^100
The base is even, so the mod 4 part is simple, but the mod 25 part needs a cycle.
- Mod 4. 2^100 is divisible by 4, so the remainder is 0.
- Mod 25. 2^10 = 1024 ≡ 24 ≡ −1. Then 2^20 ≡ 1, and 2^100 = (2^20)^5 ≡ 1.
- Combine. The candidates are 1, 26, 51, 76. Their remainders mod 4 are 1, 2, 3, 0. We need 0, so the answer is 76.
The answer is 76. This is a well-known result: 2^100 ends in 76.
Worked example 3: a multiple of 5
Find the last two digits of 15^7.
- Mod 4. 15 ≡ 3 (mod 4) and 7 is odd, so the remainder is 3.
- Mod 25. 15 is a multiple of 5 and the exponent is at least 2, so the remainder is 0.
- Combine. The candidates are 0, 25, 50, 75. Their remainders mod 4 are 0, 1, 2, 3. We need 3, so the answer is 75.
Check: 15^3 = 3375 ends in 75, and multiplying 75 by 15 gives 1125, which ends in 25. Wait: that is the last two digits of 15^4, not of 15^7. Continuing, 25 × 15 = 375 ends in 75. The sequence of endings from 15^3 onward is 75, 25, 75, 25, 75. So 15^3, 15^5 and 15^7 all end in 75, which agrees with the split method. The pattern depends on whether the exponent is odd or even, which is the mod 4 rule again.
Worked example 4: exponent reduced mod 20
Find the last two digits of 13^99.
- Mod 4. 13 ≡ 1 (mod 4), so the remainder is 1.
- Mod 25. 13^20 ≡ 1, and 99 = 20 × 4 + 19, so 13^99 ≡ 13^19. Multiplying 13^19 by 13 gives 13^20 ≡ 1. So 13^19 is the inverse of 13 mod 25. Since 13 × 2 = 26 ≡ 1, the inverse is 2. The remainder is 2.
- Combine. The candidates are 2, 27, 52, 77. Their remainders mod 4 are 2, 3, 0, 1. We need 1, so the answer is 77.
The answer is 77. Check: 13 × 77 = 1001, which ends in 01. This confirms that 77 is the inverse of 13 mod 100, as the exponent 99 ≡ −1 (mod 20) predicts.
Checking a hand answer in code
The first function below follows the three steps exactly. The loop then compares it with Python's built-in pow(a, n, 100) over many bases and exponents.
def combine(r4, r25):
# Return the one x in 0..99 with x % 4 == r4 and x % 25 == r25.
for k in range(4):
x = r25 + 25 * k
if x % 4 == r4:
return x
def last_two(a, n):
return combine(pow(a, n, 4), pow(a, n, 25))
print(last_two(7, 2026)) # 49
print(last_two(2, 100)) # 76
print(last_two(15, 7)) # 75
print(last_two(13, 99)) # 77
ok = all(last_two(a, n) == pow(a, n, 100)
for a in range(1, 100) for n in range(1, 60))
print(ok) # TrueOn the exam you do not have code. The check is a practice tool, so you can confirm your hand method on your own examples.
Choosing between the split and the direct cycle
Use the split when:
- the base is not close to 1 or −1 mod 100, so the 10k+1 pattern does not apply
- you do not remember a mod 100 cycle for the base
- the base is even, because the mod 4 part becomes 0 immediately
Use the direct cycle or the 10k+1 pattern when the base is something like 51, 49, 99 or 101. These take one line each, and the split would add steps.
Common errors
- Reducing the exponent mod 20 for a multiple of 5. The rule a^20 ≡ 1 (mod 25) needs gcd(a, 5) = 1. For 10^n or 15^n, the mod 25 remainder is 0 once n ≥ 2.
- Forgetting the small exponents. The shortcuts "even base gives 0 mod 4" and "multiple of 5 gives 0 mod 25" need n ≥ 2. For n = 1, just compute a mod 4 and a mod 25 directly.
- Treating a remainder of 3 as −3. For a ≡ 3 (mod 4), write 3 ≡ −1, not −3.
- Combining in the wrong order. Always list the four candidates r25, r25 + 25, r25 + 50, r25 + 75, then test each against r4. Listing multiples of 4 and testing mod 25 also works, but it takes longer because the multiples of 4 in 0 to 99 number 25.
- Stopping at the mod 25 answer. The mod 25 remainder alone gives four possible last-two-digit pairs. You still need the mod 4 step.
Summary
- A remainder mod 100 is fixed by the remainders mod 4 and mod 25.
- Mod 4: even bases give 0 for n ≥ 2, and odd bases behave like 1 or (−1)^n.
- Mod 25: multiples of 5 give 0 for n ≥ 2, and other bases satisfy a^20 ≡ 1, often with a shorter cycle.
- Combine by testing r25, r25 + 25, r25 + 50, r25 + 75 against the mod 4 remainder.
Exercise
Find the last two digits of 3^1000 using the mod 4 and mod 25 split.
Show answer
Mod 4: 3 ≡ −1 and 1000 is even, so 3^1000 ≡ 1. Mod 25: 3 is not a multiple of 5, so 3^20 ≡ 1, and 1000 = 20 × 50, so 3^1000 ≡ 1. The candidates are 1, 26, 51, 76 with remainders mod 4 of 1, 2, 3, 0. We need 1, so the last two digits are 01.
Exercise
Find the last two digits of 6^50. Then explain why a mod 25 cycle is not needed for 6^n here, or work it out with the split and say which part is quicker.
Show answer
Mod 4: 6 is even and the exponent is at least 2, so 6^50 ≡ 0. Mod 25: 6^5 = 7776 ≡ 7776 − 7775 = 1, since 25 × 311 = 7775. So 6^50 = (6^5)^10 ≡ 1. The candidates are 1, 26, 51, 76 with remainders mod 4 of 1, 2, 3, 0. We need 0, so the last two digits are 76. The mod 25 part is the longer one, because you need to find that 6^5 ≡ 1. Mod 4 takes one line.