Skip to main content

Modular Inverse Calculator – a⁻¹ mod m

Quick answer

This calculator finds a⁻¹ mod m where a·a⁻¹≡1: 3⁻¹ mod 7 = 5, 2⁻¹ mod 5 = 3.

  • Existence requires gcd(a,m)=1; extended-Euclid steps shown.
  • Verified every time.

Figures are estimates from this calculator’s standard formula — adjust the inputs in the tool below for your exact number.

How the Modular Inverse Calculator Works

a·a⁻¹ ≡ 1 (mod m), exists ⇔ gcd(a, m) = 1

The modular inverse of a is the number that multiplies it to 1 modulo m. Since 3×5 = 15 = 2×7+1, we write 3⁻¹ ≡ 5 (mod 7); similarly 2⁻¹ ≡ 3 (mod 5) because 6 = 5+1. The calculator uses the extended Euclidean algorithm and shows every step: for 3 mod 7, back-substituting 7 = 2×3+1 gives 1 = 7−2×3, so −2 ≡ 5 is the inverse. Existence is not guaranteed — the inverse exists only when gcd(a,m) = 1, so 4 has no inverse modulo 8 (gcd 4) while 3 does modulo 8 (3⁻¹ = 3, since 9 ≡ 1). Applications anchor cryptography: RSA decryption exponents are modular inverses of the encryption exponent mod φ(n), and affine ciphers decode through a⁻¹ mod 26. The tool also verifies the result by multiplying back and reducing.

  1. 1

    Enter a and modulus m

    Such as 3 and 7

  2. 2

    Check coprimality

    gcd(a,m) must equal 1 or no inverse exists

  3. 3

    Run extended Euclid

    Bézout coefficients expose the inverse

  4. 4

    Verify by multiplication

    a × a⁻¹ mod m must reduce to 1

Use Cases

RSA Decryption

The private exponent d is e⁻¹ mod φ(n) — the key-generation step

Affine Ciphers

Decrypt by multiplying by a⁻¹ mod 26

Modular Division

x/a mod m is computed as x × a⁻¹ mod m

Tips

  • 1

    No inverse unless gcd(a,m) = 1

  • 2

    The inverse, if present, is unique within 1…m−1

  • 3

    Self-inverses exist: 3×3 ≡ 1 (mod 8)

Common Mistakes

  • Assuming every a has an inverse — 4 fails modulo 8

  • Reporting the raw Bézout coefficient when it is negative; add m

  • Confusing a⁻¹ mod m with 1/a in the rationals

  • Forgetting to verify a×a⁻¹ ≡ 1 (mod m) at the end

FAQs

What is 3⁻¹ mod 7?

5, because 3×5 = 15 ≡ 1 (mod 7).

What is 2⁻¹ mod 5?

3, since 2×3 = 6 ≡ 1 (mod 5).

Why does 4 have no inverse mod 8?

gcd(4,8) = 4 ≠ 1; every multiple of 4 stays divisible by 4, never reaching 1 mod 8.

Can a number be its own inverse?

Yes: 3×3 = 9 ≡ 1 (mod 8), and 5×5 = 25 ≡ 1 (mod 12).

How is the inverse computed?

Extended Euclid: 1 = 7 − 2×3, so −2 ≡ 5 (mod 7) is the inverse of 3.