Calculators
Modular Inverse Calculator
Find an exact modular multiplicative inverse with GCD and verification, privately in your browser.
Find x such that a × x ≡ 1 (mod m). Enter an integer a and a whole-number modulus m ≥ 2, each with up to 100 digits. Calculations stay in your browser.
How modular inverses work
A modular inverse of a modulo m is an integer x satisfying a × x ≡ 1 (mod m). It exists exactly when gcd(a, m) = 1. The extended Euclidean algorithm finds the inverse without testing every candidate. For a = 3 and m = 11, x = 4 because 3 × 4 = 12 leaves remainder 1. For a = 6 and m = 9, the GCD is 3 and no inverse exists. Negative inputs are normalized into the range 0 to m − 1; for a = −3 and m = 11, the inverse is 7. The result is the unique representative from 0 to m − 1. Enter integers of up to 100 digits, with m at least 2. Surrounding whitespace and leading zeros are accepted. Only a may have a minus sign; plus signs, decimals, separators and scientific notation are rejected. Exact browser BigInt arithmetic preserves every digit. Inputs are neither uploaded nor stored.
Frequently Asked Questions
Everything you need to know about this tool, how it works, and privacy.
When does a modular inverse exist?
An inverse exists exactly when a and m are coprime: their greatest common divisor is 1. A prime modulus is not required.
Can a be negative or zero?
Negative a is normalized modulo m before calculation. Zero has no inverse for any supported modulus m ≥ 2.
Why must the modulus be at least 2?
This calculator uses the usual inverse convention with modulus m ≥ 2, so 0 and 1 are excluded.
Are large results exact?
Yes. Browser BigInt arithmetic handles inputs of up to 100 digits without floating-point rounding. All calculations stay on your device.