CalcSeed

Modulo Inverse Calculator

Find x such that a × x ≡ 1 (mod m), or learn why none exists.

=
Quick answer: with the default inputs (3, 7), the modular inverse is 5. At these inputs: gCD(a, m) = 1. Change any input to update the result.
Modular inverse
—

What this calculator does

Enter a number a and a modulus m and the calculator returns the modular multiplicative inverse: the value x whose product with a leaves a remainder of exactly 1 when divided by m. At the defaults, a = 3 and m = 7 give x = 5, because 3 × 5 = 15 and 15 mod 7 = 1. The calculator also reports gcd(a, m) — 1 here — which is the single gatekeeper that decides whether an inverse exists at all.

The defining condition

a·x≡1(modm)a x \equiv 1 \pmod m

The congruence means a × x and 1 differ by an exact multiple of m: for the defaults, 3 × 5 − 1 = 14 = 2 × 7, so the congruence holds. An inverse exists precisely when gcd(a, m) = 1, meaning the two numbers share no prime factor. The reason is direct: if a prime p divides both a and m, then p divides a × x for every x, so a × x can never leave a remainder of 1 — a number divisible by p cannot be congruent to 1 modulo a number also divisible by p.

Finding it with the extended Euclidean algorithm

The calculator runs the extended Euclidean algorithm, which computes gcd(3, 7) alongside two coefficients satisfying 3u + 7v = 1 — here 3 × 5 + 7 × (−2) = 15 − 14 = 1. Reading the equation modulo 7 kills the 7v term and leaves 3u ≡ 1 (mod 7), so u = 5 is the inverse. The algorithm is essentially the ordinary GCD run backwards while bookkeeping the coefficients, and it terminates in a handful of steps even for moduli with millions of digits, which is why it scales to real cryptographic key sizes.

Worked example at the defaults

GCD gate, then the coefficient

  • Inputs: a = 3, m = 7.
  • GCD check: gcd(3, 7) = 1, so an inverse exists.
  • Extended Euclid: 3 × 5 + 7 × (−2) = 1, so the coefficient of 3 is 5.
  • Verify: 3 × 5 = 15, and 15 mod 7 = 1.
  • Result: the inverse of 3 modulo 7 is 5.

A second quick example shows the machinery on a composite modulus: the inverse of 3 modulo 11 is 4, since 3 × 4 = 12 ≡ 1 (mod 11). But the inverse of 3 modulo 9 does not exist, because gcd(3, 9) = 3: every multiple of 3 — 3, 6, 12, 15, 21 — is divisible by 3, and none of them can leave a remainder of 1 when divided by 9. The GCD line in the output is the whole story before any algorithm runs.

Inverses modulo small numbers

amgcd(a, m)InverseCheck
37153 × 5 = 15 ≡ 1 (mod 7)
311143 × 4 = 12 ≡ 1 (mod 11)
49174 × 7 = 28 ≡ 1 (mod 9)
512155 × 5 = 25 ≡ 1 (mod 12)
393noneMultiples of 3 cannot be ≡ 1 (mod 9)
6102noneBoth even, so no inverse exists

Two patterns stand out in the table. First, a number can be its own inverse — 5 works modulo 12 because 25 = 2 × 12 + 1 — and self-inverses satisfy a ² ≡ 1 (mod m). Second, shared factors kill the inverse every time, even one as small as 2: since 6 and 10 are both even, 6x is always even and can never be one more than a multiple of 10, which is even. When m is prime, any a from 1 to m − 1 is automatically invertible.

Why modular inverses matter

  • Modular division: computing 2/3 modulo 7 means 2 × inverse(3) = 2 × 5 = 10 ≡ 3 (mod 7), turning division into multiplication.
  • Cryptography: RSA decryption literally raises a message to the inverse exponent, and the private key d is the inverse of e modulo a number derived from the factorization.
  • Solving congruences: equations like 3x ≡ 2 (mod 7) are solved by multiplying both sides by the inverse, giving x ≡ 2 × 5 = 10 ≡ 3 (mod 7).
  • Hashing and checksums: modular arithmetic with inverses distributes values uniformly across buckets.

The congruence-solving case is worth walking through once more, because it shows the inverse doing real work: to solve 3x ≡ 2 (mod 7), multiply both sides by the inverse 5 to get x ≡ 10 ≡ 3 (mod 7). The check is 3 × 3 = 9 ≡ 2 (mod 7), exactly the right side. Without the inverse there is no systematic route — only trial and error across seven candidates.

Common mistakes

  • Assuming an inverse always exists: gcd(3, 9) = 3 means the inverse of 3 modulo 9 is undefined, no matter how many candidates you try.
  • Reporting a negative coefficient as the inverse: extended Euclid may produce −2, and the actual inverse is −2 + 7 = 5. Wrap the coefficient into the range 0 to m − 1.
  • Confusing the inverse with the additive inverse: the additive inverse of 3 modulo 7 is 4, since 3 + 4 ≡ 0, while the multiplicative inverse 5 satisfies 3 × 5 ≡ 1. The two answer different questions.
  • Forgetting the uniqueness range: 5, 12, 19 and −2 all satisfy 3x ≡ 1 (mod 7), but only the representative in 0–6, which is 5, is the standard inverse.

The universal verification is one multiplication: take your candidate x, compute a × x, and check whether the remainder mod m is 1. If it is, the inverse is correct; if not, no adjustment of that candidate will fix it — either you wrapped a negative wrong or no inverse exists.

Where to go next

Modular arithmetic starts with remainders, and the modulo calculator computes a mod b for any pair — useful for verifying the 15 mod 7 = 1 step above. The GCD & LCM calculator shows the Euclidean algorithm’s forward pass on any inputs, which is the first half of the extended algorithm used here, and a prime number checker helps establish the coprimality condition when the modulus is a large composite.

Frequently asked questions

What is the modular inverse of 3 modulo 7?

5. Because 3 × 5 = 15 and 15 mod 7 = 1. In equation form, 3 × 5 + 7 × (−2) = 1 shows where the 5 comes from.

When does a modular inverse not exist?

When gcd(a, m) is greater than 1. The inverse of 3 modulo 9 does not exist because gcd(3, 9) = 3, and every multiple of 3 leaves a remainder divisible by 3, never 1.

How do I find a modular inverse by hand?

Run the extended Euclidean algorithm to express 1 as a combination of a and m, then read off the coefficient of a and wrap it positive. For 3 and 7: 3 × 5 + 7 × (−2) = 1, so the inverse is 5.

Is the modular inverse unique?

It is unique within 0 to m − 1. All solutions differ by whole multiples of m — for 3 mod 7 the values …, −2, 5, 12, … all work, and 5 is the standard representative.

How do I use an inverse to solve a congruence like 3x = 2 (mod 7)?

Multiply both sides by the inverse: x ≡ 2 × 5 = 10 ≡ 3 (mod 7). Check: 3 × 3 = 9 ≡ 2 (mod 7), which matches.

Can a number be its own modular inverse?

Yes, when a ² ≡ 1 (mod m). The inverse of 5 modulo 12 is 5 itself, since 5 × 5 = 25 = 2 × 12 + 1.

What is the difference between the multiplicative and additive inverse?

The multiplicative inverse of 3 modulo 7 is 5 because 3 × 5 ≡ 1; the additive inverse is 4 because 3 + 4 ≡ 0. When people say modular inverse they almost always mean the multiplicative one.

Why does RSA depend on modular inverses?

The private exponent d is the inverse of the public exponent e modulo a value derived from the prime factors. Only someone who can compute that inverse — which requires the factorization — can decrypt.

What happens when the modulus is prime?

Every number from 1 to p − 1 has an inverse modulo a prime p, since a prime shares no factor with smaller numbers. Modulo 7, the inverses of 1 through 6 are 1, 4, 5, 2, 3 and 6.

Method and sources

Calculation basis

Results follow exact mathematical definitions; the arithmetic is deterministic and can be verified by hand from the steps shown.

Last updated: November 17, 2026
Formula & data sources
  • Extended Euclidean algorithm for the modular multiplicative inverse.

Cite this page

Reference formats
APA 7CalcSeed. (2026, November 17). Modulo Inverse Calculator. https://calcseed.com/c/math/modulo-inverse-calculator/
MLA 9"Modulo Inverse Calculator." CalcSeed, 17 Nov. 2026, calcseed.com/c/math/modulo-inverse-calculator/.
ChicagoCalcSeed. "Modulo Inverse Calculator." Last modified November 17, 2026. https://calcseed.com/c/math/modulo-inverse-calculator/

Related calculators

More Math calculators