Inverse Modulo Calculator

Find the modular multiplicative inverse a⁻¹ mod m using the Extended Euclidean Algorithm with step-by-step EEA table, Euler method, verification, and invertible-elements reference.

a mod m
3
3 mod 7 = 3
GCD(a, m)
1
Coprime — inverse exists
Modular Inverse
5
3 × 5 ≡ 1 (mod 7)
φ(m) — Euler's Totient
6
Number of integers 1…6 coprime to 7
Euler Inverse
5
a^(φ(m)−1) mod m = 3^5 mod 7
Verification
Enter x to verify
Type a candidate in the verify field

Extended Euclidean Algorithm Steps

StepQuotient (q)Remainder (r)st
10310
221-21
3307-3

Inverse Existence

3⁻¹ mod 7 = 5
Invertible integers in 1…6: 6 of 6 (100.0%)

Invertible Elements mod 7

aa⁻¹ mod 7a × a⁻¹ mod 7
111
241
351
421
531
661

Multiplication Table mod 7 (row × col)

×0123456
00000000
10123456
20246135
30362514
40415263
50531642
60654321
Planning notes, formulas, and examples

About the Inverse Modulo Calculator

The **Inverse Modulo Calculator** finds the modular multiplicative inverse of a number — the value x such that a × x ≡ 1 (mod m). This concept is central to modular arithmetic, cryptography (RSA, Diffie–Hellman), and coding theory. A modular inverse exists if and only if GCD(a, m) = 1, meaning a and m must be coprime.

This page applies the **Extended Euclidean Algorithm** (EEA) to compute the inverse efficiently, displaying every intermediate quotient, remainder, and Bézout coefficient in a clear step-by-step table. It also supports an alternative derivation through **Euler's theorem**: a^(φ(m)−1) mod m, where φ(m) is Euler's totient function. Both methods are shown side by side so students and developers can compare approaches.

Beyond finding a single inverse, the calculator lists every invertible element modulo m along with its inverse, shows a color-coded multiplication table for small moduli, and lets you verify any candidate answer. Preset examples cover common moduli used in textbooks and cryptographic contexts, making the page a compact reference for anyone studying number theory or implementing modular-inverse routines in code.

When This Page Helps

Computing modular inverses by hand is tedious, especially when the Extended Euclidean Algorithm involves many steps. This calculator exposes every intermediate calculation, so you can learn the method or verify homework without losing the arithmetic structure.

It also goes beyond a bare answer by showing Euler's totient, listing all invertible elements, and rendering a mod-m multiplication table. That broader context helps when you need to understand the structure of Z/mZ (the integers modulo m) rather than just one isolated inverse.

How to Use the Inputs

  1. Enter the value a whose inverse you want to find.
  2. Enter the modulus m and keep it positive.
  3. Select EEA or Euler's Theorem as the computation method.
  4. Read the Modular Inverse output card for the answer, or see why no inverse exists.
  5. Optionally type a candidate in the Verify field to confirm it satisfies a × x ≡ 1 (mod m).
  6. Review the EEA Steps table to follow the algorithm step by step.
  7. Scroll down to the multiplication table (for m ≤ 20) to see all products mod m at once.
Formula used
Extended Euclidean Algorithm: express GCD(a, m) = a·s + m·t; if GCD = 1 then a⁻¹ ≡ s (mod m). Euler's method: a⁻¹ ≡ a^(φ(m)−1) (mod m) when GCD(a, m) = 1.

Example Calculation

Result: 3⁻¹ mod 7 = 5

GCD(3, 7) = 1, so the inverse exists. EEA yields s = 5, and indeed 3 × 5 = 15 ≡ 1 (mod 7).

Tips & Best Practices

  • If GCD(a, m) ≠ 1, no inverse exists — try a different value or modulus.
  • Use presets for common textbook and crypto examples.
  • The multiplication table highlights cells equal to 1 in green — each is an inverse pair.
  • Verify your hand-computed answer by entering it in the Verify field.
  • For prime m, every nonzero a has an inverse because GCD(a, p) = 1 for all 1 ≤ a < p.
  • Use the invertible-elements table to quickly see all inverse pairs for a given modulus.

Understanding the Extended Euclidean Algorithm

The standard Euclidean Algorithm repeatedly divides the larger number by the smaller, keeping the remainder, until the remainder is zero. The last nonzero remainder is the GCD. The **extended** version additionally tracks coefficients s and t (Bézout coefficients) that express GCD(a, m) = a·s + m·t. When GCD = 1, multiplying both sides by 1 shows that a·s ≡ 1 (mod m), so s (reduced mod m) is the modular inverse.

Euler's Theorem Approach

Euler's theorem states that a^φ(m) ≡ 1 (mod m) whenever GCD(a, m) = 1. Dividing both sides by a gives a^(φ(m)−1) ≡ a⁻¹ (mod m). Computing the totient φ(m) requires the prime factorization of m, which can be expensive for large m, but for small m or known-prime m the approach is straightforward and connects the inverse to group theory.

Practical Cryptographic Applications

In RSA, the private exponent d is the modular inverse of the public exponent e modulo φ(n). Computing d is exactly the operation this calculator performs. Similarly, in Diffie–Hellman and elliptic-curve cryptography, modular inverses appear when dividing or solving discrete-log-related equations. Understanding how the EEA works is therefore essential for anyone studying or implementing public-key cryptography.

Sources & Methodology

Last updated:

Frequently Asked Questions

  • It is the integer x such that a × x ≡ 1 (mod m). It exists only when GCD(a, m) = 1.