Last updated: July 31, 2026
Inverse Modulo Calculator
Creators
Dharmendra SinghReviewers

Creators
Dharmendra SinghReviewers
Creators
Dharmendra SinghReviewers

Creators
Dharmendra SinghReviewers
Formula
Find x such that a·x ≡ 1 (mod m). A modular inverse exists only when gcd(a, m) = 1.
Where:
- a=Integer to invert(integer)
- m=Modulus(integer)
- gcd(a,m)=Greatest common divisor(integer)
- x=Modular inverse(integer)
Worked Examples
Classic modular inverse
Find the multiplicative inverse of 3 modulo 7.
- 1Run the extended Euclidean algorithm on 3 and 7.
- 2The gcd is 1, so an inverse exists.
- 3Normalize the coefficient of 3 into the range 0 to 6.
Another coprime pair
Check a slightly larger example used in number theory practice.
- 1Compute gcd(10,17) = 1.
- 2Use the Bézout coefficient for 10.
- 3Reduce the coefficient modulo 17.
Negative input normalization
The calculator can normalize a negative coefficient after the algorithm.
- 1Evaluate gcd(-3,11), which is still 1.
- 2Compute a Bézout coefficient for -3.
- 3Wrap the result into the standard residue class modulo 11.
No inverse exists
If the numbers are not coprime, the inverse is undefined.
- 1Compute gcd(4,6) = 2.
- 2Because the gcd is not 1, no multiplicative inverse exists.
- 3The calculator returns an error instead of a misleading residue.
Introduction
The inverse modulo calculator finds multiplicative inverses in modular arithmetic using the extended Euclidean algorithm. It also reports gcd(a, m) so you can see immediately whether the inverse exists. This is helpful in number theory, cryptography, and modular equation solving.
What a modular inverse means
A modular inverse undoes multiplication inside a modular system, much like reciprocal values undo multiplication over real numbers.
You seek x such that a×x ≡ 1 mod m.
The result is always interpreted modulo m.
The inverse is unique modulo m when it exists.
The gcd test decides existence.
Inverse values help solve congruences.
They are foundational in modular arithmetic.
Why coprime numbers matter
The inverse exists only when a and m share no factor other than 1.
Compute gcd(a, m) first.
If gcd is 1, an inverse exists.
If gcd is greater than 1, no inverse exists.
Shared factors block the congruence a×x ≡ 1.
This condition is both necessary and sufficient.
The calculator shows gcd explicitly.
A gcd greater than 1 means every value of a×x shares that factor, so it can never equal 1 modulo m.
How the extended Euclidean algorithm helps
The extended Euclidean algorithm finds integers u and v such that au + mv = gcd(a, m).
Start with the pair (a, m).
Repeatedly divide and take remainders.
Back-substitute to find Bézout coefficients.
Use the coefficient of a as the inverse seed.
Reduce that coefficient modulo m.
Normalize it to a non-negative answer.
Input rules
This calculator expects integer input because modular inverses are defined in integer arithmetic.
a must be an integer.
m must be an integer greater than 1.
Fractions are not accepted.
Infinity and NaN are rejected.
Negative a values are allowed.
The final inverse is normalized modulo m.
How to read the result
The primary output is the inverse, and the supporting output is the gcd.
Use inverse as the multiplicative inverse modulo m.
Check gcd to confirm validity.
A gcd of 1 means the answer is usable.
A gcd above 1 means the result is undefined.
You can test the output with modular multiplication.
Results are normalized to the standard residue range.
Common uses of modular inverses
Modular inverses appear in many arithmetic workflows where division is replaced by multiplication.
Solving linear congruences.
Working with fractions modulo a prime.
Simplifying modular algebra exercises.
Implementing cryptographic formulas.
Checking textbook examples.
Supporting modular division in programming.
Mistakes to avoid
The most common errors come from forgetting the gcd rule or entering non-integer data.
Using a modulus of 1.
Entering decimal values.
Ignoring a gcd greater than 1.
Forgetting to reduce the coefficient modulo m.
Confusing additive inverse with multiplicative inverse.
Not checking the result by multiplication.
FAQs
What is a modular inverse?
It is a number x such that a×x leaves remainder 1 when divided by m.
When does a modular inverse exist?
A modular inverse exists exactly when gcd(a, m) = 1.
Why does the calculator show gcd?
The gcd tells you whether the inverse exists and explains any invalid result.
Can a be negative?
Yes. The calculator still finds a valid inverse and normalizes it into the usual modular range.
Why must m be greater than 1?
Modulo 1 arithmetic collapses every integer to 0, so a multiplicative inverse is not meaningful there.
Can I use decimal inputs?
No. This calculator is for integer modular arithmetic only.
How do I verify the answer?
Multiply a by the reported inverse and reduce modulo m. The remainder should be 1.