Calculate the modular multiplicative inverse (a · x ≡ 1 mod m) and the modular additive inverse (a + x ≡ 0 mod m) instantly. The calculator uses the extended Euclidean algorithm and displays the step-by-step solution with verification.
Modular Inverse Calculator
a · x = 1 mod m
How to use the calculator
- Select the inverse type: Multiplicative or Additive.
- Enter the value of a (any integer).
- Enter the modulus m (integer ≥ 2).
- Click Calculate. The result shows the equation, the solution and the verification.
Modular multiplicative inverse
The modular multiplicative inverse of a with respect to modulus m is the integer x such that:
a · x ≡ 1 (mod m)
It exists only when gcd(a, m) = 1 (a and m are coprime). It is computed using the extended Euclidean algorithm, which finds integers x and y such that a·x + m·y = 1.
| a | m | Inverse x | Verification |
|---|---|---|---|
| 2 | 3 | 2 | 2 · 2 = 4 ≡ 1 mod 3 |
| 3 | 7 | 5 | 3 · 5 = 15 ≡ 1 mod 7 |
| 5 | 11 | 9 | 5 · 9 = 45 ≡ 1 mod 11 |
| 7 | 13 | 2 | 7 · 2 = 14 ≡ 1 mod 13 |
Modular additive inverse
The modular additive inverse of a with respect to modulus m is the integer x such that:
a + x ≡ 0 (mod m)
It always exists and equals x = m − (a mod m) when a mod m ≠ 0, or x = 0 when a is a multiple of m.
| a | m | Inverse x | Verification |
|---|---|---|---|
| 2 | 3 | 1 | 2 + 1 = 3 ≡ 0 mod 3 |
| 5 | 7 | 2 | 5 + 2 = 7 ≡ 0 mod 7 |
| 9 | 5 | 1 | 9 + 1 = 10 ≡ 0 mod 5 |
| 6 | 3 | 0 | 6 + 0 = 6 ≡ 0 mod 3 |
Frequently asked questions
What is the modular multiplicative inverse?
The modular multiplicative inverse of a with respect to modulus m is the value x such that a · x ≡ 1 (mod m). It exists only when gcd(a, m) = 1 and is computed using the extended Euclidean algorithm.
What is the modular additive inverse?
The modular additive inverse of a with respect to modulus m is x such that a + x ≡ 0 (mod m). It always exists: x = m − (a mod m) when a mod m ≠ 0; or x = 0 when a is a multiple of m.
When does the modular multiplicative inverse exist?
Only when gcd(a, m) = 1 — that is, when a and m share no common factor greater than 1. If gcd(a, m) > 1, the equation a·x ≡ 1 (mod m) has no solution.
How do you calculate the modular multiplicative inverse?
Use the extended Euclidean algorithm: find integers x and y such that a·x + m·y = gcd(a, m). If gcd = 1, then a·x ≡ 1 (mod m) and x (reduced to the range [0, m−1]) is the desired inverse.
See also…
