Inputs
Example Data
| # | a | m | Expected inverse | |
|---|---|---|---|---|
| 1 | 3 | 11 | 4 | |
| 2 | 10 | 17 | 12 | |
| 3 | 14 | 33 | 26 | |
| 4 | 123456 | 100003 | 33792 | |
| 5 | -19 | 101 | 85 |
Click Use to auto-fill inputs from the row.
Result
Enter values and click Calculate to see the inverse and steps.
Formula Used
We solve a · x ≡ 1 (mod m). An inverse exists iff gcd(a, m) = 1. Using the Extended Euclidean Algorithm, find integers u, v such that u·m + v·a = gcd(a, m). When gcd = 1, the inverse is x ≡ v (mod m).
At termination: old_s·m + old_t·a_norm = gcd(a, m). If gcd = 1 ⇒ a_norm·old_t ≡ 1 (mod m) ⇒ inverse ≡ old_t (mod m).
How to Use
- Enter any integer a and modulus m > 1.
- Click Calculate. The tool normalizes negative or large
ato[0, m-1]. - View whether an inverse exists and, if yes, its least positive residue.
- Inspect the Extended Euclidean steps and Bezout coefficients.
- Export the results to CSV or PDF, or copy the summary.
Tip: Use the shareable link to preserve inputs for bookmarking or sharing.
FAQs
a and m>1, an inverse is an integer x with a·x ≡ 1 (mod m). It’s unique modulo m.gcd(a, m) = 1. If gcd > 1, the congruence a·x ≡ 1 has no solution.a modulo m to a canonical representative in [0, m-1]. The inverse is returned as the least positive residue.m. We report the smallest non-negative one; any other differs by a multiple of m.a by the reported inverse and reduce modulo m. The remainder must be 1.RSA Mini Examples (d = e-1 mod φ(n))
These toy examples show the inverse of the public exponent e modulo φ(n), producing the secret exponent d when it exists.
| # | p | q | n = p·q | φ(n) | e | d | Note |
|---|---|---|---|---|---|---|---|
| 1 | 53 | 59 | 3127 | 3016 | 17 | 2129 | |
| 2 | 43 | 47 | 2021 | 1932 | 5 | 773 | |
| 3 | 61 | 53 | 3233 | 3120 | 3 | — | No inverse, e not coprime with φ(n) |
In practice use large safe primes and adequate padding; these are illustrative only.
Reference: Inverses for Small Moduli
Quick lookup of a^{-1} (mod m) for small m and several a values.
| # | m | a | inverse | gcd(a,m) |
|---|---|---|---|---|
| 1 | 7 | 2 | 4 | 1 |
| 2 | 7 | 3 | 5 | 1 |
| 3 | 7 | 4 | 2 | 1 |
| 4 | 7 | 5 | 3 | 1 |
| 5 | 11 | 2 | 6 | 1 |
| 6 | 11 | 3 | 4 | 1 |
| 7 | 11 | 4 | 3 | 1 |
| 8 | 11 | 5 | 9 | 1 |
| 9 | 13 | 2 | 7 | 1 |
| 10 | 13 | 3 | 9 | 1 |
| 11 | 13 | 4 | 10 | 1 |
| 12 | 13 | 5 | 8 | 1 |
| 13 | 17 | 2 | 9 | 1 |
| 14 | 17 | 3 | 6 | 1 |
| 15 | 17 | 4 | 13 | 1 |
| 16 | 17 | 5 | 7 | 1 |
Rows with “—” indicate no inverse because a shares a factor with m.