Modular Inverse Calculator – a⁻¹ mod m
This calculator finds a⁻¹ mod m where a·a⁻¹≡1: 3⁻¹ mod 7 = 5, 2⁻¹ mod 5 = 3.
- Existence requires gcd(a,m)=1; extended-Euclid steps shown.
- Verified every time.
Figures are estimates from this calculator’s standard formula — adjust the inputs in the tool below for your exact number.
How the Modular Inverse Calculator Works
The modular inverse of a is the number that multiplies it to 1 modulo m. Since 3×5 = 15 = 2×7+1, we write 3⁻¹ ≡ 5 (mod 7); similarly 2⁻¹ ≡ 3 (mod 5) because 6 = 5+1. The calculator uses the extended Euclidean algorithm and shows every step: for 3 mod 7, back-substituting 7 = 2×3+1 gives 1 = 7−2×3, so −2 ≡ 5 is the inverse. Existence is not guaranteed — the inverse exists only when gcd(a,m) = 1, so 4 has no inverse modulo 8 (gcd 4) while 3 does modulo 8 (3⁻¹ = 3, since 9 ≡ 1). Applications anchor cryptography: RSA decryption exponents are modular inverses of the encryption exponent mod φ(n), and affine ciphers decode through a⁻¹ mod 26. The tool also verifies the result by multiplying back and reducing.
- 1
Enter a and modulus m
Such as 3 and 7
- 2
Check coprimality
gcd(a,m) must equal 1 or no inverse exists
- 3
Run extended Euclid
Bézout coefficients expose the inverse
- 4
Verify by multiplication
a × a⁻¹ mod m must reduce to 1
Use Cases
RSA Decryption
The private exponent d is e⁻¹ mod φ(n) — the key-generation step
Affine Ciphers
Decrypt by multiplying by a⁻¹ mod 26
Modular Division
x/a mod m is computed as x × a⁻¹ mod m
Tips
- 1
No inverse unless gcd(a,m) = 1
- 2
The inverse, if present, is unique within 1…m−1
- 3
Self-inverses exist: 3×3 ≡ 1 (mod 8)
Common Mistakes
Assuming every a has an inverse — 4 fails modulo 8
Reporting the raw Bézout coefficient when it is negative; add m
Confusing a⁻¹ mod m with 1/a in the rationals
Forgetting to verify a×a⁻¹ ≡ 1 (mod m) at the end
FAQs
What is 3⁻¹ mod 7?
What is 2⁻¹ mod 5?
Why does 4 have no inverse mod 8?
Can a number be its own inverse?
How is the inverse computed?
Related tools
Pick another tool to continue your calculation.
Riemann Sum Calculator – Left, Right & Midpoint
Calculate approximate integral using Riemann sum.
Signed Magnitude Converter – 8-Bit Binary
Convert between decimal and binary signed magnitude.
Divisor Sum Calculator – σ(n) Function
Calculate sum of divisors and Euler functions.
Stirling’s Approximation Calculator – n! Estimate
Calculate factorial using Stirling's approximation.
Euler-Mascheroni Constant γ Calculator
Calculate the Euler-Mascheroni constant gamma to high precision.
Jacobi Symbol Calculator – (a/n)
Calculate the Jacobi symbol (a/n).