What this calculator does
This modular multiplicative inverse calculator finds the inverse of an integer a under modulus m. In simple terms, it finds a number x such that:
If such an x exists, modular division becomes possible. If it does not exist, the calculator explains why.
When does a modular inverse exist?
A modular inverse exists if and only if gcd(a, m) = 1. That means a and m are coprime. If they share a common factor greater than 1, no inverse exists.
- Inverse exists: a = 3, m = 11 because gcd(3,11)=1
- No inverse: a = 12, m = 18 because gcd(12,18)=6
How the calculator works
The tool uses the Extended Euclidean Algorithm. This algorithm efficiently computes integers x and y satisfying:
When gcd(a,m)=1, the value of x is the inverse (adjusted into the standard range 0 to m−1).
Why this matters
- Essential for RSA and many cryptographic systems
- Used in modular arithmetic problems in algebra and number theory
- Needed for dividing under a modulus in coding competitions
Examples
Example 1: inverse of 3 mod 11
The result is 4, because 3 × 4 = 12 and 12 ≡ 1 (mod 11).
Example 2: inverse of 10 mod 17
The result is 12, because 10 × 12 = 120 and 120 ≡ 1 (mod 17).
Example 3: inverse of 8 mod 20
No inverse exists because gcd(8,20)=4, not 1.
Tips for correct input
- Use integers only (negative values are accepted for a)
- Use a modulus greater than 1
- If the number is larger than the modulus, that is fine—the calculator reduces it automatically
Quick FAQ
Can modulus be negative?
The calculator converts a negative modulus to its positive equivalent, because modular arithmetic is typically defined with positive modulus.
What if a is zero?
Zero has no multiplicative inverse modulo m (for m > 1), since 0 multiplied by anything is still 0, never 1.
Is this suitable for large integers?
Yes. The calculator uses JavaScript BigInt, so it supports very large whole numbers far beyond normal floating-point limits.
Final note
Modular inverse is one of the most useful ideas in discrete math and cryptography. Use this tool whenever you need fast, accurate inverse computation with clear reasoning and validation.