Advanced

Modular Inverse Calculator

Compute the modular multiplicative inverse of an integer a modulo m using the extended Euclidean algorithm.
Integer to invert
Must be greater than 1
Modular inverse
3^-1 = 4 (mod 11)
Inverse x
4
a reduced mod m
3
gcd(a, m)
1
Check (a·x) mod m
1
01.42.84.15.56.98.39.611Inverse x lies within [0, m)
Results are estimates for general information only and are not professional advice — always verify important results independently before relying on them. Read the full disclaimer.
Quick answer

How does this calculator work?

The modular inverse of a modulo m is the integer x in [0, m) where a·x ≡ 1 (mod m). It exists only when gcd(a, m) = 1, and is found with the extended Euclidean algorithm, then normalized to a positive residue. If a and m share a factor, no inverse exists.

Formula
a · x ≡ 1 (mod m), exists iff gcd(a, m) = 1
How this is calculated

The number a is reduced modulo m into the range [0, m), and the modulus m must be an integer greater than 1. The extended Euclidean algorithm is then run on (a mod m, m), producing both the greatest common divisor gcd(a, m) and a Bezout coefficient x such that a·x + m·y = gcd(a, m).

A modular inverse exists only when gcd(a, m) = 1. When it does, the raw coefficient x can be negative, so it is normalized into [0, m) with ((x mod m) + m) mod m. The returned inverse satisfies (a · x) mod m = 1, shown in the verification stat. If gcd(a, m) ≠ 1, no inverse exists and the divisor is reported instead.

All arithmetic uses BigInt internally to avoid precision loss with large integers. Inputs must be integers; non-integer values are rejected. Negative values of a are handled by reduction, so for example -8 mod 11 is treated as 3.

Frequently asked questions

An inverse of a modulo m exists only when a and m are coprime, that is gcd(a, m) = 1. If they share a common factor greater than 1, no integer x satisfies a·x ≡ 1 (mod m).

No. The modulus can be any integer greater than 1. When m is prime, every a from 1 to m−1 has an inverse because all are coprime to m, but composite moduli also work for any a coprime to m.

The number a is first reduced into the range [0, m) before the algorithm runs, so negative inputs are treated by their positive residue. The resulting inverse is also normalized to lie in [0, m).

Also known as

multiplicative inverse mod
inverse modulo
extended euclidean
mod inverse
modular multiplicative inverse

APA

TG we-Calculate Editorial Team. (2026). Modular Inverse Calculator [Online calculator]. TG we-Calculate. https://we-calculate.com/calculator/modular-inverse-calculator

Chicago

TG we-Calculate Editorial Team. "Modular Inverse Calculator." TG we-Calculate. 2026. https://we-calculate.com/calculator/modular-inverse-calculator.

IEEE

TG we-Calculate Editorial Team, "Modular Inverse Calculator," TG we-Calculate, 2026. [Online]. Available: https://we-calculate.com/calculator/modular-inverse-calculator

BibTeX

@misc{wecalculate_modular_inverse_calculator, title = {Modular Inverse Calculator}, author = {{TG we-Calculate Editorial Team}}, howpublished = {\url{https://we-calculate.com/calculator/modular-inverse-calculator}}, year = {2026}, note = {TG we-Calculate} }

Did this calculator help you?