How to find a modular inverse
A modular inverse undoes multiplication within one modulus. This page handles the multiplicative inverse only; it does not generate RSA keys or factor numbers.
How to use
- Enter any integer a, including a negative value.
- Enter a positive modulus m greater than 1.
- Calculate to get the unique representative x from 0 through m − 1, when it exists.
- Read the Bézout line and the actual product remainder to verify the answer independently.
Condition and formula
An inverse exists exactly when gcd(a, m) = 1. The extended Euclidean algorithm finds coefficients u and v with a·u + m·v = 1; u reduced modulo m is the inverse.
Negative a is first normalized as ((a mod m) + m) mod m. The displayed answer is always the least non-negative representative.
Worked examples
3 modulo 11
gcd(3, 11) = 1, and 3 × 4 = 12. Because 12 mod 11 = 1, the inverse is 4.
−3 modulo 11
−3 normalizes to 8. Since 8 × 7 = 56 and 56 mod 11 = 1, the inverse is 7.
6 modulo 9
gcd(6, 9) = 3, so no integer multiplied by 6 can leave remainder 1 modulo 9.
Input limits and scope
- Each input is limited to 200 decimal digits to keep browser work responsive. Leading zeros still count toward the typed limit.
- Only base-10 integers are accepted. Decimals, scientific notation, spaces inside a number, typed units, and Infinity are rejected.
- A modulus of 0, 1, or a negative number is invalid. a = 0 is accepted but has no inverse for m > 1.
- The result is an exact integer, not a decimal approximation. This calculator is an arithmetic aid, not a cryptographic key generator or security service.
Frequently asked questions
Why must the GCD equal 1?
If a and m share a factor greater than 1, every product a×x shares that factor and cannot be congruent to 1 modulo m.
Can a negative integer have an inverse?
Yes. It is reduced to its least non-negative residue before the same coprimality test.
Why is there only one displayed answer?
All inverses differ by a multiple of m. The calculator displays the unique one in the range 0 to m − 1.
Is this the same as 1/a?
No. A modular inverse is an integer whose product has remainder 1 under a chosen modulus.