Modular Inverse — Definition, Formula & Examples
The modular inverse of an integer modulo is the integer such that multiplying by gives a remainder of 1 when divided by . It exists only when and share no common factors other than 1.
Given integers and with , the modular inverse of modulo is the unique integer in satisfying .
Key Formula
Where:
- = The integer whose inverse you want to find
- = The modular inverse of a modulo m
- = The modulus
How It Works
Finding a modular inverse is like solving a division problem in modular arithmetic — since you cannot directly divide, you multiply by the inverse instead. To find it, you can test values of from 1 to , use the Extended Euclidean Algorithm, or apply Euler's theorem: , where is Euler's totient function. For a prime modulus , this simplifies to by Fermat's Little Theorem. The inverse exists if and only if .
Worked Example
Problem: Find the modular inverse of 3 modulo 7.
Step 1: You need an integer such that . Since 7 is prime, you can use Fermat's Little Theorem: .
Step 2: Reduce 243 modulo 7.
Step 3: Verify: multiply 3 by 5 and check the remainder.
Answer: The modular inverse of 3 modulo 7 is .
Why It Matters
Modular inverses are essential in cryptography — the RSA encryption algorithm relies on computing them with very large primes. They also appear in competition math problems and in solving systems of linear congruences using the Chinese Remainder Theorem.
Common Mistakes
Mistake: Trying to find a modular inverse when (e.g., the inverse of 4 modulo 8).
Correction: The modular inverse only exists when and are coprime. Always check first.
