Home › Advanced Math & Statistics › Modular inverse Modular inverse calculator This modular inverse calculator finds the modular multiplicative inverse of an integer \(a\) modulo \(m\). In other words, it finds an integer \(x\) such that \(a x \equiv 1 \pmod m\), or tells you when no such inverse exists. The tool is built for students, engineers and cryptography practitioners who need a reliable, step-by-step implementation of the extended Euclidean algorithm. Integer \(a\) Any non-zero integer. The calculator will automatically reduce it modulo \(m\). Modulus \(m\) Positive integer > 1. For cryptography, \(m\) is often a large prime or product of primes. Show extended Euclidean algorithm steps Compute modular inverse Reset Quick examples Click an example to auto-fill the fields and see a typical modular inverse computation. a = 3, m = 11 a = 17, m = 43 a = 35, m = 64 a = −7, m = 26 Result Extended Euclidean algorithm steps The table below shows the recurrence for the extended Euclidean algorithm applied to the reduced value \(a' = a \bmod m\) and the modulus \(m\). Step q r s t What is a modular inverse? Given an integer \(a\) and a modulus \(m > 1\), a modular multiplicative inverse of \(a\) modulo \(m\) is an integer \(x\) such that \[ a x \equiv 1 \pmod m. \] Intuitively, \(x\) plays the role of a reciprocal of \(a\) in modular arithmetic: multiplying by \(x\) “undoes” the effect of multiplying by \(a\), but only up to congruence modulo \(m\). Existence and uniqueness A modular inverse exists if and only if \(\gcd(a, m) = 1\) (that is, \(a\) and \(m\) are coprime). If an inverse exists, it is unique modulo \(m\) . All solutions differ by a multiple of \(m\). If \(\gcd(a, m) > 1\), then no modular inverse exists. Algorithm used by this calculator This calculator uses the extended Euclidean algorithm , a classic number-theoretic method that not only computes \(\gcd(a, m)\) but also finds integers \(x\) and \(y\) such that \[ a x + m y = \gcd(a, m). \] When \(\gcd(a, m) = 1\), the coefficient \(x\) is precisely a modular inverse of \(a\) modulo \(m\). We then reduce \(x\) to the standard range \(0 \le x \le m-1\). Extended Euclidean algorithm (high-level outline) Reduce the input \(a\) modulo \(m\): set \(a' = a \bmod m\). Initialize \(r_0 = a'\), \(r_1 = m\), \(s_0 = 1\), \(s_1 = 0\), \(t_0 = 0\), \(t_1 = 1\). Repeat until \(r_k = 0\): Compute the quotient \(q_k = \lfloor r_{k-1}
Subcategories in Home › Advanced Math & Statistics › Modular inverse Modular inverse calculator This modular inverse calculator finds the modular multiplicative inverse of an integer \(a\) modulo \(m\). In other words, it finds an integer \(x\) such that \(a x \equiv 1 \pmod m\), or tells you when no such inverse exists. The tool is built for students, engineers and cryptography practitioners who need a reliable, step-by-step implementation of the extended Euclidean algorithm. Integer \(a\) Any non-zero integer. The calculator will automatically reduce it modulo \(m\). Modulus \(m\) Positive integer > 1. For cryptography, \(m\) is often a large prime or product of primes. Show extended Euclidean algorithm steps Compute modular inverse Reset Quick examples Click an example to auto-fill the fields and see a typical modular inverse computation. a = 3, m = 11 a = 17, m = 43 a = 35, m = 64 a = −7, m = 26 Result Extended Euclidean algorithm steps The table below shows the recurrence for the extended Euclidean algorithm applied to the reduced value \(a' = a \bmod m\) and the modulus \(m\). Step q r s t What is a modular inverse? Given an integer \(a\) and a modulus \(m > 1\), a modular multiplicative inverse of \(a\) modulo \(m\) is an integer \(x\) such that \[ a x \equiv 1 \pmod m. \] Intuitively, \(x\) plays the role of a reciprocal of \(a\) in modular arithmetic: multiplying by \(x\) “undoes” the effect of multiplying by \(a\), but only up to congruence modulo \(m\). Existence and uniqueness A modular inverse exists if and only if \(\gcd(a, m) = 1\) (that is, \(a\) and \(m\) are coprime). If an inverse exists, it is unique modulo \(m\) . All solutions differ by a multiple of \(m\). If \(\gcd(a, m) > 1\), then no modular inverse exists. Algorithm used by this calculator This calculator uses the extended Euclidean algorithm , a classic number-theoretic method that not only computes \(\gcd(a, m)\) but also finds integers \(x\) and \(y\) such that \[ a x + m y = \gcd(a, m). \] When \(\gcd(a, m) = 1\), the coefficient \(x\) is precisely a modular inverse of \(a\) modulo \(m\). We then reduce \(x\) to the standard range \(0 \le x \le m-1\). Extended Euclidean algorithm (high-level outline) Reduce the input \(a\) modulo \(m\): set \(a' = a \bmod m\). Initialize \(r_0 = a'\), \(r_1 = m\), \(s_0 = 1\), \(s_1 = 0\), \(t_0 = 0\), \(t_1 = 1\). Repeat until \(r_k = 0\): Compute the quotient \(q_k = \lfloor r_{k-1}.