Multiplicative Inverse Modulo Calculator

Find a modular inverse for coprime integers using the Extended Euclidean Algorithm.

Modular inverse calculator
Enter an integer and modulus to solve for the least nonnegative inverse.

About the multiplicative inverse modulo calculator

A multiplicative inverse modulo m is an integer that reverses multiplication within modular arithmetic. For an integer a, an inverse x satisfies the condition that a times x has remainder 1 when divided by m. This is often written as a times x is congruent to 1 modulo m. For example, 3 times 4 equals 12, and 12 leaves remainder 1 when divided by 11, so 4 is the multiplicative inverse of 3 modulo 11. An inverse does not exist for every pair of integers. The necessary and sufficient condition is that a and m are coprime, which means their greatest common divisor is 1. Consider 6 modulo 9: every multiple of 6 shares a factor of 3 with 9, so none can leave remainder 1. In contrast, 7 and 26 have gcd 1, and the inverse of 7 modulo 26 is 15 because 105 leaves remainder 1 after division by 26. The calculator tests the gcd before reporting an answer. The Extended Euclidean Algorithm efficiently finds the inverse. The ordinary Euclidean Algorithm repeatedly divides and takes remainders to compute the greatest common divisor. The extended version tracks coefficients so that the gcd can be expressed as an integer combination of the original inputs. When the gcd equals 1, the coefficient multiplying a is an inverse. That coefficient may be negative, so the calculator reduces it modulo m and displays the least nonnegative representative from zero through m minus one. Modular inverses let you divide within a congruence system. To solve a times x congruent to b modulo m, multiply b by the inverse of a, provided the inverse exists. They are important in linear congruences, the Chinese Remainder Theorem, modular fractions, hashing, error-detection methods, and public-key cryptography. RSA key generation, for instance, includes finding an exponent inverse modulo a totient. Real cryptographic implementations use arbitrary-precision, carefully audited libraries rather than ordinary browser numbers. Enter whole numbers only and use a modulus greater than 1. Negative values for a are valid because each negative integer has an equivalent least nonnegative residue modulo m. The calculator uses safe JavaScript integers, which is appropriate for classroom exercises and moderate number-theory problems. It displays the gcd and a direct multiplication check, allowing you to confirm that the reported inverse really produces remainder 1. For very large cryptographic inputs, use software designed for big integers and security-sensitive computations.

Modular inverse examples

Each result is the least nonnegative integer whose product leaves remainder 1.

Number and modulusInverseVerification
3 modulo 114Three times 4 equals 12, and 12 mod 11 equals 1.
7 modulo 2615Seven times 15 equals 105, and 105 mod 26 equals 1.
17 modulo 31202753Seventeen times 2753 leaves remainder 1 modulo 3120.
10 modulo 1712Ten times 12 equals 120, and 120 mod 17 equals 1.

How to calculate a modular inverse

  1. Enter the integer whose multiplicative inverse you want.
  2. Enter an integer modulus greater than 1.
  3. Select Calculate modular inverse to run the Extended Euclidean Algorithm.
  4. Confirm that the displayed product has remainder 1 under the modulus.

Multiplicative inverse modulo FAQ

When does a multiplicative inverse modulo exist?

An inverse exists exactly when the number and modulus are coprime. Equivalently, their greatest common divisor must equal 1.

Why are there multiple-looking inverse answers?

Adding any whole multiple of the modulus produces a congruent representative. The calculator standardizes the result by displaying the least nonnegative inverse.

How does the Extended Euclidean Algorithm find the inverse?

It computes the gcd while tracking coefficients for the original numbers. When the gcd is 1, the coefficient of the input number becomes a modular inverse.

Can I calculate an inverse for a negative number?

Yes, a negative integer can first be reduced to its equivalent residue modulo m. The calculator handles that reduction and returns a least nonnegative inverse.

How are modular inverses used in cryptography?

They help reverse modular multiplication in algorithms such as RSA and elliptic-curve systems. Security applications require big-integer and constant-time implementations beyond this educational calculator.