CalcWorldHub
Free online calculator · no signup

Modular inverse calculator

Find the least nonnegative residue x whose product with a is congruent to 1 modulo m.

Modular inverse calculator — Integer a, Positive modulus m and calculation method
Modular inverse calculator: inputs and calculation method.

How to use this calculator

Find the least nonnegative residue x whose product with a is congruent to 1 modulo m.

  1. Enter Integer a, Positive modulus m. Match the units shown beside each field and review the result together with the assumptions below.
  2. Read the worked example below to check the expected input format and result.
  3. Compare another scenario by changing one input at a time. Use Reset to return to the starting values.
Calculation guide

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

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.

Related calculators