Compute modular inverses instantly with clear inputs and robust validation. Pick Extended Euclid or Fermat for verified prime moduli. Try Binary EEA for efficient coefficient updates too. Run batch jobs, upload CSV, export to PDF. See steps, factor insights, and verify residues precisely today.
Enter values and press Compute inverse to see results here.
| a | m | Inverse | Check (a×inv mod m) |
|---|---|---|---|
| 3 | 11 | 4 | 1 |
| 10 | 17 | 12 | 1 |
| 7 | 26 | 15 | 1 |
| 17 | 43 | 38 | 1 |
| 35 | 64 | 11 | 1 |
| 19 | 121 | 51 | 1 |
You can reproduce each step: enter the values above, select a method, and compare the verification column with these results.
The inverse of a modulo m is a number x satisfying a·x ≡ 1 (mod m). It exists iff gcd(a,m)=1.
| Setting | Condition | Existence of inverse | How to compute |
|---|---|---|---|
| General modulus m | gcd(a, m) = 1 | Exists and is unique mod m | Extended Euclid or Binary EEA |
| Prime modulus p | a ≢ 0 (mod p) | Always exists | EEA or Fermat: ap−2 mod p |
| Prime power pk | p ∤ a | Exists | EEA modulo pk (Hensel lifting optional) |
| Composite m with CRT | gcd(a, m) = 1 | Exists | Invert mod each prime-power, combine via CRT |
| Method | Works for | Time (rough) | Pros | Cons |
|---|---|---|---|---|
| Extended Euclidean | Any m | O(log m) | Deterministic, returns Bézout coefficients | Needs divisions |
| Binary EEA | Any m | O(log m) | Uses shifts/subtractions, simple arithmetic | Trace a bit longer |
| Fermat ap−2 mod p | Prime m | O(log p) multiplications | Easy with fast exponentiation | Invalid if m is composite |
| a | m | gcd(a,m) | Inverse | Outcome |
|---|---|---|---|---|
| 14 | 21 | 7 | — | No inverse (not coprime) |
| 0 | 7 | 7 | — | No inverse (not coprime) |
| -5 | 11 | 1 | 9 | Inverse exists |
| 12 | 35 | 1 | 3 | Inverse exists |
| Application | Task | How inverse is used |
|---|---|---|
| Modular division | Solve a·x ≡ b (mod m) | x ≡ b·a−1 (mod m) when gcd(a,m)=1 |
| Chinese Remainder Theorem | Combine solutions mod coprime moduli | Needs inverses of moduli residues to build recombination weights |
| RSA key math | Compute d from e·d ≡ 1 (mod φ(n)) | d = e−1 mod φ(n) via EEA |
| Elliptic curves | Point addition in finite fields | Slope = (y₂−y₁)·(x₂−x₁)−1 mod p |
For a modulo m, an inverse exists only when gcd(a, m) = 1. If the gcd is not one, the equation a·x ≡ 1 (mod m) has no solution, and modular division by a is undefined.
Extended Euclidean is the default, fast, and deterministic for any modulus. Binary EEA avoids divisions using shifts. Fermat’s method works only for prime moduli and uses fast exponentiation a^(p−2) mod p.
Yes. The calculator normalizes inputs and outputs into the standard residue class. The reported inverse is always shown within the range [0, m−1] to simplify verification and downstream computations.
Fermat’s method requires a prime modulus p and a not divisible by p. If the modulus is composite, a^(p−2) mod p is invalid. The tool auto-checks primality and warns to prevent misuse.
First compute a’s inverse modulo m, provided gcd(a, m) = 1. Then x ≡ b·a^(−1) (mod m). Enter a and m, get the inverse, and multiply by b modulo m to obtain the solution.
There is no inverse, but a·x ≡ b (mod m) may have solutions if gcd(a, m) divides b. Reduce by the gcd and solve in the smaller modulus, or factor m and use the Chinese Remainder Theorem.
This tool handles typical 64‑bit sized moduli comfortably. Extended Euclid and Binary EEA scale logarithmically. For extremely large cryptographic sizes, specialized big‑integer libraries and optimized number‑theoretic implementations are recommended.
Important Note: All the Calculators listed in this site are for educational purpose only and we do not guarentee the accuracy of results. Please do consult with other sources as well.