Sub topic 7
Last One and Two Digits of a Power
Assume you can divide integers, work with positive integer powers, and find basic remainders. This chapter uses congruence notation. The statement \(a \equiv b \pmod n\) means that \(a\) and \(b\) leave the same remainder when divided by \(n\).
Convert digits into remainders
The last digit of an integer is its remainder modulo 10:
\[ N \bmod 10 \]
The last two digits are its remainder modulo 100. Write a one-digit remainder with a leading zero when necessary. For example, a remainder of 4 modulo 100 means the last two digits are 04.
Therefore:
- To find the last digit of \(a^k\), calculate \(a^k \pmod {10}\).
- To find the last two digits of \(a^k\), calculate \(a^k \pmod {100}\).
You do not need to calculate the complete power. Find the repeating pattern of remainders instead.
Find the cycle
Consider powers of 7 modulo 10:
| Power | Remainder modulo 10 |
|---|---|
| \(7^1\) | 7 |
| \(7^2\) | 9 |
| \(7^3\) | 3 |
| \(7^4\) | 1 |
| \(7^5\) | 7 |
The cycle is \(7,9,3,1\), with length 4. To find the last digit of \(7^{100}\), divide the exponent by 4:
\[ 100 \bmod 4=0 \]
A remainder of zero means use the last value in the cycle. Thus, the last digit is 1.
The same base can have a different cycle modulo 100. For powers of 7, the first terms are:
\[ 07,\ 49,\ 43,\ 01,\ 07,\ldots \]
The cycle still has length 4, so \(7^{100}\) ends in 01.
print([pow(7, k, 10) for k in range(1, 9)])
# [7, 9, 3, 1, 7, 9, 3, 1]
print(pow(7, 100, 100))
# 1The Python function pow(a, k, n) calculates \(a^k \pmod n\) efficiently. The remainder 1 modulo 100 represents the last two digits 01.
Use a shorter cycle when possible
Some bases have immediate shortcuts:
- A power of a number ending in 0 ends in 0.
- A power of a number ending in 5, with positive exponent, ends in 5.
- Powers of an even number eventually end in 00 for sufficiently large exponents if the base contains enough factors of 2 and 5.
- Powers of 2 have a last-digit cycle of \(2,4,8,6\).
- Powers of 5 have a last-digit cycle of 5.
For other bases, generate remainders until the starting value repeats. Do not assume every cycle has length 4 modulo 100. For example, powers of 3 have a longer cycle modulo 100.
A CAT method
For a power question under time pressure:
- Identify whether the question asks for one digit or two digits.
- Use modulus 10 or 100.
- Find a cycle, or reduce the base first.
- Reduce the exponent by the cycle length.
- Read the matching cycle entry.
- Add a leading zero if the two-digit answer has only one digit.
Exercise
Find the last two digits of 3^20. The remainders of powers of 3 modulo 100 repeat after 20 powers, and 3^20 ≡ 01 (mod 100).
Show answer
01