Modular Inverse Calculator — (a × x) ≡ 1 (mod m)
Find the integer x such that (a × x) ≡ 1 (mod m) — the modular multiplicative inverse of a. An inverse exists if and only if gcd(a, m) = 1.
The unique x in [0, m−1] such that (a × x) mod m = 1
How does this calculator work?
The modular inverse x satisfies (a × x) mod m = 1 and exists only when gcd(a, m) = 1. It is found using the extended Euclidean algorithm, which solves a·x + m·y = 1 for x, then reduces x to [0, m − 1]. Enter a and m to get the unique inverse or a "no inverse" message.
Formula
How this is calculated
The modular multiplicative inverse of a integer a with respect to modulus m is the integer x in [0, m − 1] such that (a × x) ≡ 1 (mod m) — meaning a × x leaves remainder 1 when divided by m. This is the modular analogue of the ordinary multiplicative inverse (reciprocal) in regular arithmetic.
An inverse exists if and only if a and m are coprime, i.e. their greatest common divisor gcd(a, m) = 1. If gcd(a, m) > 1, no such x exists and the calculator reports this. The extended Euclidean algorithm finds integers x and y satisfying Bézout's identity a·x + m·y = gcd(a, m). When gcd = 1, x is the modular inverse, which is then reduced to the canonical range [0, m − 1] by computing ((x mod m) + m) mod m.
Modular inverses are fundamental in number theory and modern cryptography. RSA key generation relies on modular inverses to compute the private-key exponent; they also appear in the Chinese Remainder Theorem, Montgomery multiplication and discrete-logarithm algorithms. The result is always unique within [0, m − 1] when it exists.
Frequently asked questions
When a and m share a common factor greater than 1 (gcd(a, m) > 1). For example, 2 has no inverse mod 4 because gcd(2, 4) = 2. If m is prime, every non-zero a has an inverse, which is why primes are favoured in cryptographic applications.
In modular arithmetic you cannot divide directly. Instead, multiplying by the inverse of a achieves the same effect: a/b ≡ a × b⁻¹ (mod m). This lets you solve linear congruences and compute fractions within modular systems.
Yes — within [0, m − 1] the inverse is unique when it exists. All other solutions differ by multiples of m, so x + k·m is also a solution for any integer k, but only one value falls in the canonical range.
Also known as
TG we-Calculate Editorial Team. (2026). Modular Inverse Calculator — (a × x) ≡ 1 (mod m) [Online calculator]. TG we-Calculate. https://we-calculate.com/calculator/inverse-modulo-calculator
TG we-Calculate Editorial Team. "Modular Inverse Calculator — (a × x) ≡ 1 (mod m)." TG we-Calculate. 2026. https://we-calculate.com/calculator/inverse-modulo-calculator.
TG we-Calculate Editorial Team, "Modular Inverse Calculator — (a × x) ≡ 1 (mod m)," TG we-Calculate, 2026. [Online]. Available: https://we-calculate.com/calculator/inverse-modulo-calculator
@misc{wecalculate_inverse_modulo_calculator, title = {Modular Inverse Calculator — (a × x) ≡ 1 (mod m)}, author = {{TG we-Calculate Editorial Team}}, howpublished = {\url{https://we-calculate.com/calculator/inverse-modulo-calculator}}, year = {2026}, note = {TG we-Calculate} }
Did this calculator help you?
