Sub topic 6
Remainders of Large Powers by Finding the Cycle
Prerequisites
Assume you can divide integers, find remainders, and use positive integer powers. We write
\[ a \equiv r \pmod n \]
when \(a\) and \(r\) have the same remainder after division by \(n\).
The key idea is that powers often repeat their remainders. Once you find the repeating cycle, reduce the large exponent to a position inside that cycle.
Finding a Cycle
To find \(a^k \pmod n\):
- Calculate successive powers of \(a\), reducing each result modulo \(n\).
- Stop when a previous remainder appears.
- Record the cycle length.
- Locate the required exponent within the cycle.
For example, find \(7^{100}\) 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\). Since
\[ 100 \div 4 \]
has remainder \(0\), the 100th power has the same remainder as the fourth power:
\[ 7^{100} \equiv 7^4 \equiv 1 \pmod {10}. \]
Therefore, the last digit of \(7^{100}\) is \(1\).
print([pow(7, k, 10) for k in range(1, 9)])
# [7, 9, 3, 1, 7, 9, 3, 1]
print(pow(7, 100, 5))
# 1The Python function pow(a, k, n) calculates \(a^k \pmod n\) efficiently. It is useful for checking work, but in a CAT question you should usually identify the cycle manually.
Using the Cycle Position
Suppose a cycle has length \(L\). Divide the exponent \(k\) by \(L\).
- If \(k \bmod L\) is nonzero, use that position.
- If \(k \bmod L = 0\), use the final position, \(L\), not position zero.
For the cycle \(7,9,3,1\), an exponent with remainder \(2\) corresponds to the second entry, \(9\). An exponent divisible by \(4\) corresponds to the fourth entry, \(1\).
A Faster Cycle with Negative Remainders
Sometimes a base is close to a convenient multiple of the modulus. For example,
\[ 7 \equiv -2 \pmod 9. \]
Thus,
\[ 7^4 \equiv (-2)^4 = 16 \equiv 7 \pmod 9. \]
This can be faster than multiplying by \(7\) repeatedly. Always reduce after each operation so that the numbers stay small.
>``callout tip >Check the cycle from the beginning. A repeated remainder does not always mean that the cycle starts immediately, especially when the base and modulus have a common factor. >``
Common Errors
- Using \(k \bmod L=0\) as position zero instead of position \(L\).
- Confusing the cycle length with the number of powers already calculated.
- Reducing the exponent without first proving or finding a cycle.
- Reporting a remainder outside \(0\) through \(n-1\).
Exercise
Find the remainder when 3^45 is divided by 10.
Show answer
The remainders cycle as 3, 9, 7, 1, with length 4. Since 45 mod 4 = 1, use the first position. The remainder is 3.