Modular Inverse Calculator

Find a⁻¹ mod m

CalculatorsFreeNo Signup
4.8(649 reviews)
All Tools

Loading tool...

About Modular Inverse Calculator

A modular inverse calculator that finds x such that ax ≡ 1 (mod m) using the extended Euclidean algorithm. Shows GCD computation steps, Bézout coefficients, and verifies the result. Handles cases where no inverse exists (gcd(a,m) ≠ 1). All calculations are client-side. Essential for cryptography, number theory, and modular arithmetic.

Modular Inverse Calculator Features

  • a⁻¹ mod m
  • Ext. Euclidean
  • Bézout coeffs
  • Verification
  • Step-by-step
The modular inverse of a mod m is x where ax ≡ 1 (mod m). Exists iff gcd(a,m) = 1 (coprime). Found via Extended Euclidean Algorithm: ax + my = gcd(a,m). If gcd=1, then x mod m is the inverse. Critical in RSA encryption: d = e⁻¹ mod φ(n).

How to Use

Enter a and m:

  • a: Number to invert
  • m: Modulus
  • Output: a⁻¹ mod m

Extended Euclidean

Compute gcd(a,m) while tracking coefficients x,y such that ax+my=gcd. If gcd=1, x mod m is the inverse.

Cryptography

RSA: choose e, compute d = e⁻¹ mod φ(n). d is the private key. Without efficient modular inverse, RSA key generation is impossible.

Step-by-Step Instructions

  1. 1Enter a.
  2. 2Enter modulus m.
  3. 3View inverse (if exists).
  4. 4See algorithm steps.
  5. 5Verify a × a⁻¹ ≡ 1 (mod m).

Modular Inverse Calculator — Frequently Asked Questions

When does the modular inverse not exist?+

When gcd(a,m) ≠ 1. For example, 4⁻¹ mod 6 doesn't exist because gcd(4,6)=2. Both must be coprime (share no common factor).

Why is this important for RSA?+

RSA generates public key e and needs private key d = e⁻¹ mod φ(n). The extended Euclidean algorithm efficiently finds d, making RSA key generation practical.

Is there always a unique inverse?+

Yes, when it exists. If ax ≡ 1 (mod m), the inverse modulo m is unique: x mod m. Different representations (x, x+m, x+2m, ...) are all equivalent.

Share this tool: