In modular arithmetic, the inverse of a modulo m is the number x that satisfies a·x ≡ 1 (mod m) — the clock-arithmetic cousin of the reciprocal. This Inverse Modulo Calculator finds that inverse with the extended Euclidean algorithm and prints the verification multiplication, so the congruence is proved, not just claimed.





Worked Examples: 3 mod 11 and 10 mod 17

For a = 3 and m = 11 the calculator returns x = 4, and the check shows why: 3 × 4 = 12 = 11 + 1, so 12 ≡ 1 (mod 11) — multiplying by 3 then by 4 on an 11-hour clock lands back at 1. For a = 10 and m = 17 it returns x = 12: 10 × 12 = 120 = 7 × 17 + 1, so 120 ≡ 1 (mod 17). Both inverses are unique modulo m — any other solution differs from these by a multiple of the modulus. Try a = 6, m = 9 and the calculator refuses: gcd(6, 9) = 3, and multiples of 6 modulo 9 only ever hit 0, 3, 6 — never 1 — so no inverse exists.

The Extended Euclidean Algorithm

The inverse exists exactly when gcd(a, m) = 1, and the extended Euclidean algorithm both tests that condition and constructs the inverse. It runs Euclid’s remainder sequence while tracking how each remainder is built from a and m, ending with Bézout’s identity: some combination s·a + t·m = gcd(a, m) = 1. Reducing that identity modulo m kills the t·m term, leaving s·a ≡ 1 (mod m) — so s, adjusted into the range 0 to m−1, is the inverse. For 3 and 11: 11 = 3×3 + 2, 3 = 2×1 + 1, and back-substituting gives 1 = 3 − 1×2 = 3 − 1×(11 − 3×3) = 4×3 − 1×11, hence 3⁻¹ ≡ 4 (mod 11). Brute-force search (try a×1, a×2, …) works for small moduli, but the extended algorithm stays fast at the thousand-digit sizes cryptography uses.

Where Modular Inverses Work

RSA encryption chooses the private exponent d as the modular inverse of the public exponent e modulo φ(n) — the entire key pair is one inverse computation. Solving congruences: 3x ≡ 7 (mod 11) falls immediately once 3⁻¹ = 4 is known: x ≡ 4×7 = 28 ≡ 6 (mod 11), and indeed 3×6 = 18 ≡ 7. Hashing and checksums use multiplication by units modulo 2³², possible only for odd multipliers — odd exactly means invertible modulo a power of two. Affine ciphers, the classical a·x + b letter encoding, are decryptable only when a has an inverse modulo 26, which is why only 12 of the 26 multipliers are legal keys. In each case the gcd = 1 condition is the gatekeeper.

Common Mistakes

Assuming every number has an inverse modulo m — only numbers coprime to m do. Forgetting to reduce a negative Bézout coefficient into range: −7 is a valid inverse modulo 11, but the standard answer is 4, its positive representative (add m until in range). Confusing the modular inverse with the ordinary reciprocal: 3⁻¹ mod 11 is the integer 4, not the fraction 1/3 — clock arithmetic has no fractions. And checking a·x ≡ 1 with the wrong modulus after reducing a mod m along the way — reduce consistently, then verify against the original m.

A Second Full Run: The Inverse of 7 Modulo 26

The affine-cipher modulus makes a satisfying hand example. Euclid’s chain for 7 and 26: 26 = 7 × 3 + 5; 7 = 5 × 1 + 2; 5 = 2 × 2 + 1. Back-substitute from the bottom: 1 = 5 − 2 × 2 = 5 − 2 × (7 − 5) = 3 × 5 − 2 × 7 = 3 × (26 − 3 × 7) − 2 × 7 = 3 × 26 − 11 × 7. Reading the last identity modulo 26 erases the 3 × 26 term and leaves −11 × 7 ≡ 1 (mod 26), so the inverse of 7 is −11, lifted into range as −11 + 26 = 15. The check the calculator prints confirms it: 7 × 15 = 105 = 4 × 26 + 1. Every step is forced — each remainder is determined by the last two numbers — which is why the algorithm has been essentially unchanged since Euclid wrote it down around 300 BCE, and why it still sits inside the key-generation code of modern cryptosystems, just with far larger numbers.

From Inverses to Whole Equation Systems

Once single inverses are cheap, bigger structures open. A linear congruence a·x ≡ b (mod m) with gcd(a, m) = 1 has the unique solution x ≡ a⁻¹·b. Pairs of congruences — x ≡ 2 (mod 3), x ≡ 3 (mod 5), x ≡ 2 (mod 7) — are assembled by the Chinese remainder theorem into a single class modulo 105 (this system solves to x ≡ 23 (mod 105): 23 leaves remainder 2 on division by 3, remainder 3 on division by 5, and remainder 2 on division by 7), and the theorem’s construction multiplies modular inverses exactly like the one this page computes. Calendar puzzles, rotating-roster schedules and hash-function design all reduce, at their core, to these two moves: invert where coprime, and combine where moduli are coprime.

Related Tools

Continue with the Reciprocal Calculator, the GCF Calculator, the Factor Calculator, or browse the full Math Calculators hub.

Frequently Asked Questions

What is the modular inverse of 3 modulo 11?

Four, because 3 × 4 = 12 ≡ 1 (mod 11). The inverse is the multiplier that lands the product on 1.

When does a modular inverse not exist?

When gcd(a, m) is greater than 1. Then every multiple of a shares that factor modulo m and can never reach 1 — for example 6 has no inverse mod 9.

How is a modular inverse different from a reciprocal?

The reciprocal 1/a is a fraction in ordinary arithmetic. The modular inverse is an integer x with a·x ≡ 1 (mod m) — same inverse idea, inside clock arithmetic.

Is the modular inverse unique?

Yes, modulo m: if x works, the full solution set is x plus multiples of m, so exactly one answer lives in 0 to m−1.

How do I solve 3x ≡ 7 (mod 11)?

Multiply both sides by the inverse of 3, which is 4: x ≡ 28 ≡ 6 (mod 11). Check: 3 × 6 = 18 ≡ 7 (mod 11).

Why does RSA need modular inverses?

The private key exponent is defined as the inverse of the public exponent modulo φ(n). Encryption and decryption then cancel each other precisely because the exponents are modular inverses.