How to use this calculator
Find the least nonnegative residue x whose product with a is congruent to 1 modulo m.
- Enter Integer a, Positive modulus m. Match the units shown beside each field and review the result together with the assumptions below.
- Read the worked example below to check the expected input format and result.
- Compare another scenario by changing one input at a time. Use Reset to return to the starting values.
How Modular inverse calculator works
Find the least nonnegative residue x whose product with a is congruent to 1 modulo m.
Inputs and units
- Integer a: a is a safe integer whose inverse is sought.
- Positive modulus m: m is an integer modulus from 2 through 10¹².
Formula and method
x=a⁻¹ mod m satisfies ax≡1 (mod m). It exists exactly when gcd(a,m)=1; the extended Euclidean algorithm produces it.
Worked example
For a=3 and m=11, 3·4=12≡1 (mod 11), so the inverse is 4.
Interpreting the result
The result is a residue in 0,…,m−1 and is not ordinary division by a decimal approximation.
Assumptions and limits
If a and m share a factor, no modular inverse exists. The modulus is restricted to 2 through 10¹², and a must be an exactly represented safe integer.
Sources and method
- A modular inverse exists exactly when the value is relatively prime to the modulus. Stanford: modular division
Frequently asked questions
Why can an inverse fail to exist?
A residue is invertible only when it is relatively prime to the modulus.
Is the inverse unique?
There is one unique residue modulo m, represented here in the range 0 through m−1.
How do I use the Modular inverse calculator?
Enter Integer a, Positive modulus m. Match the units shown beside each field and review the result together with the assumptions below.
What is a worked example of Modular inverse?
For a=3 and m=11, 3·4=12≡1 (mod 11), so the inverse is 4.
What does the Modular inverse calculator calculate?
Find the least nonnegative residue x whose product with a is congruent to 1 modulo m.