Sub topic 4
Negative Remainders as a Shortcut
Prerequisites and the main idea
Assume you can divide integers, find ordinary remainders, and use congruence notation. Recall that
\[ a \equiv b \pmod n \]
means that \(a\) and \(b\) leave the same remainder when divided by \(n\). Equivalently, \(n\) divides \(a-b\).
The standard remainder is usually chosen from \(0\) through \(n-1\). However, a negative number can be a much shorter representative of the same congruence class.
For example:
\[ 97 \equiv 7 \pmod {10} \]
but also
\[ 97 \equiv -3 \pmod {10}, \]
because \(97-(-3)=100\), which is divisible by \(10\). The ordinary remainder is \(7\), while \(-3\) is a convenient negative representative.
Turning large numbers into small negative numbers
If a number is close to a multiple of the modulus, subtract that multiple and use the small difference.
For instance,
\[ 98 \equiv -3 \pmod {101} \]
because \(98=101-3\). This is useful when multiplying:
\[ 98\cdot 103 \pmod {101} \]
becomes
\[ (-3)(2)=-6. \]
Since \(-6\equiv 95\pmod {101}\), the required ordinary remainder is
\[ \boxed{95}. \]
The negative result is not the final standard remainder. Convert it by adding the modulus until it lies between \(0\) and \(n-1\).
| Working result | Modulus | Standard remainder |
|---|---|---|
| \(-6\) | \(101\) | \(95\) |
| \(-1\) | \(50\) | \(49\) |
| \(-12\) | \(7\) | \(2\) |
Powers and negative representatives
Negative representatives are especially effective for powers. If a base is one less than a multiple of the modulus, write it as \(-1\).
For example:
\[ 49^{37}\pmod {50} \]
has
\[ 49\equiv -1\pmod {50}. \]
Therefore,
\[ 49^{37}\equiv (-1)^{37}=-1\equiv 49\pmod {50}. \]
The odd exponent keeps the negative sign. If the exponent were even, the result would be \(1\).
Another example is
\[ 7^{100}\pmod 8. \]
Because \(7\equiv -1\pmod 8\),
\[ 7^{100}\equiv (-1)^{100}=1\pmod 8. \]
This avoids calculating a very large power.
# Negative representatives make modular powers small.
print(pow(49, 37, 50)) # 49
print(pow(7, 100, 8)) # 1
# Python returns the standard non-negative remainder.
print((-1) % 50) # 49Common errors
- Treating \(-3\) as the ordinary remainder when dividing \(97\) by \(10\). The ordinary remainder is \(7\).
- Forgetting to reduce every factor. If \(a\equiv r\pmod n\) and \(b\equiv s\pmod n\), then \(ab\equiv rs\pmod n\).
- Losing the sign of \((-1)^k\). It is \(1\) for even \(k\) and \(-1\) for odd \(k\).
- Adding the wrong modulus when converting a negative result.
Under CAT time pressure, first check whether the base is close to \(0\), \(1\), or \(-1\) modulo the divisor. A negative representative often removes the need for a cycle or long multiplication.
Exercise
Find the remainder when 199^25 is divided by 200.
Show answer
Since 199 ≡ -1 (mod 200), 199^25 ≡ (-1)^25 = -1 ≡ 199 (mod 200). The remainder is 199.