Modular inverses are the “division” of modular arithmetic. They are essential in RSA and elliptic-curve cryptography, in the Chinese remainder theorem and in hash functions and random number generators.
How to use the Inverse Modulo Calculator
- Inverse type
- a
- Modulus m
Everything is calculated in your browser, so results appear instantly and nothing you type is sent to a server.
How it works
The extended Euclidean algorithm finds integers x and y with a·x + m·y = gcd(a, m). When the gcd is 1, x (reduced modulo m) is the inverse. The table of divisions is shown so you can follow the steps.
Formula
Multiplicative: a·x ≡ 1 (mod m), exists ⇔ gcd(a, m) = 1
Additive: x ≡ −a (mod m)
Worked example
Inputs: Inverse type: Modular multiplicative inverse; a: 3; Modulus m: 11.
Results: Inverse x = 4; Check = 3 × 4 = 12 ≡ 1 (mod 11); Steps = Extended Euclidean algorithm:
3 = 0 × 11 + 3
11 = 3 × 3 + 2
3 = 1 × 2 + 1
2 = 2 × 1 + 0
Back-substitution gives 3 × (4) + 11 × (-1) = 1, so x ≡ 4 (mod 11).
Key terms
- Modular inverse
- A number that multiplies with a to give 1 modulo m.
Frequently asked questions
What is the inverse of 3 mod 11?
4, because 3 × 4 = 12 ≡ 1 (mod 11).
When does a multiplicative inverse not exist?
When a and m share a factor, e.g. 2 has no inverse mod 4.
What is the additive inverse of 3 mod 11?
8, because 3 + 8 = 11 ≡ 0.
Can I use Fermat's little theorem?
If m is prime, a^(m−2) mod m is the inverse.