Toolstia / Modular inverse calculator
Modular inverse calculator
The modular inverse of a number a is the number x for which a times x leaves a remainder of 1 when divided by m. Enter a and m to find it, see the extended Euclidean steps and the Bezout equation, and check the result.
The modular inverse of a is the number x with a times x leaving remainder 1 when divided by m. It exists only when a and m are coprime. The extended Euclidean algorithm finds it, and it is used in RSA and other cryptography. The input a can be negative.
How it works
- Enter the number a and the modulus m.
- Read the inverse, or see that none exists.
- Follow the table of steps if you want to see the working.
When it exists
An inverse exists exactly when the greatest common divisor of a and m is 1. If not, the tool shows the divisor.
The method
The extended Euclidean algorithm divides again and again while tracking how each remainder is built from m and a. The final coefficient of a is the inverse.
Where it is used
Modular inverses are needed in RSA keys, in affine ciphers and in solving congruences.
Negative and big numbers
A negative a is reduced first. Numbers up to 60 digits are handled exactly.
Questions
Is this uploaded anywhere?
Everything happens in your browser, and nothing you enter is sent anywhere.
What is the inverse of 3 modulo 11?
It is 4, because 3 times 4 is 12, which leaves a remainder of 1 when divided by 11.
Can the modulus be 1?
The modulus must be at least 2, because everything is the same modulo 1.