Inverse Modulo Calculator
Solve inverse modulo problems step-by-step with our free calculator. See formulas, worked examples, and clear explanations.
Calculator
Adjust values & calculateFind x such that a * x mod m = 1
Extended Euclidean Algorithm Steps
Multiplication Table (mod 11)
Formula
The modular multiplicative inverse of a modulo m is the integer x in the range [1, m-1] such that a*x is congruent to 1 (mod m). It exists if and only if GCD(a, m) = 1. The Extended Euclidean Algorithm finds x by expressing GCD(a,m) = ax + my, and when GCD = 1, x mod m is the inverse.
Last reviewed: December 2025
Worked Examples
Example 1: Finding Modular Inverse Using Extended Euclidean Algorithm
Example 2: No Inverse Exists
Background & Theory
The Inverse Modulo Calculator applies the following established principles and formulas. Mathematics rests on a hierarchy of number systems, each extending the previous. The natural numbers (1, 2, 3, ...) support counting and ordering. The integers add negative values and zero, enabling subtraction without restriction. The rational numbers, expressible as p/q where p and q are integers and q is nonzero, close the system under division. The real numbers fill the gaps left by irrationals such as the square root of 2 or pi, forming a complete ordered field. The complex numbers, written as a + bi where i is the square root of negative one, complete the algebraic closure of the reals and allow every polynomial to have a root. Prime factorization states that every integer greater than one is uniquely expressible as a product of primes, a result known as the Fundamental Theorem of Arithmetic. Computing the greatest common divisor (GCD) of two integers relies most efficiently on the Euclidean algorithm: repeatedly replace the larger number with the remainder when it is divided by the smaller, until the remainder is zero. The last nonzero remainder is the GCD. The least common multiple (LCM) follows from the identity LCM(a, b) = |a * b| / GCD(a, b). Modular arithmetic defines equivalence classes of integers that share the same remainder under division by a modulus n. Fermat's Little Theorem and Euler's Theorem arise from this structure and underpin modern cryptography. Logarithms are the inverses of exponential functions. If b raised to the power x equals y, then the logarithm base b of y equals x. The natural logarithm uses base e, approximately 2.71828. Combinatorics counts arrangements and selections. The number of ordered arrangements (permutations) of r objects from n distinct objects is nPr = n! / (n - r)!. The number of unordered selections (combinations) is nCr = n! / (r! * (n - r)!). Pascal's triangle arranges these binomial coefficients so that each entry equals the sum of the two entries directly above it. The Fibonacci sequence, defined by F(1) = 1, F(2) = 1, and F(n) = F(n-1) + F(n-2), appears throughout nature and connects deeply to the golden ratio via Binet's formula.
History
The history behind the Inverse Modulo Calculator traces back through the following developments. Mathematics as a systematic discipline traces to ancient Mesopotamia. Babylonian clay tablets dating to around 1800 BCE demonstrate knowledge of quadratic equations, Pythagorean triples, and base-60 arithmetic, suggesting a practical mathematical tradition far preceding Greek formalism. Euclid of Alexandria compiled the Elements around 300 BCE, establishing the axiomatic method that would define rigorous mathematics for over two thousand years. His work organized plane geometry, number theory, and proportion into logically chained propositions derived from a small set of postulates. The algorithm bearing his name for computing GCDs appears in Book VII and remains in use today. In the 9th century, the Persian scholar Muhammad ibn Musa Al-Khwarizmi wrote Al-Kitab al-mukhtasar fi hisab al-jabr wal-muqabala, the treatise whose title gave algebra its name. He systematized the solution of linear and quadratic equations and described procedures that operated on unknowns as objects, a conceptual leap away from purely numerical calculation. Rene Descartes introduced coordinate geometry in 1637 by uniting algebra and Euclidean geometry, allowing curves to be studied through equations. This synthesis set the stage for calculus. Isaac Newton and Gottfried Wilhelm Leibniz independently developed calculus during the 1660s and 1670s, triggering a priority dispute that lasted decades and divided British and Continental mathematicians. Carl Friedrich Gauss proved the Fundamental Theorem of Algebra in 1799, showing that every nonconstant polynomial has at least one complex root. His Disquisitiones Arithmeticae of 1801 established modern number theory. David Hilbert's formalist program at the turn of the 20th century sought to place all of mathematics on an explicit axiomatic foundation, a project that Kurt Godel's incompleteness theorems of 1931 showed to be fundamentally limited. Alan Turing's work in the 1930s on computability introduced the theoretical model of the stored-program computer and linked mathematical logic directly to the limits of algorithmic calculation. His proof that no algorithm can decide in general whether an arbitrary program will halt or run forever placed fundamental boundaries on what mathematics can mechanically determine, and it opened the discipline now known as theoretical computer science.
Frequently Asked Questions
Formula
Find x such that ax mod m = 1
The modular multiplicative inverse of a modulo m is the integer x in the range [1, m-1] such that a*x is congruent to 1 (mod m). It exists if and only if GCD(a, m) = 1. The Extended Euclidean Algorithm finds x by expressing GCD(a,m) = ax + my, and when GCD = 1, x mod m is the inverse.
Worked Examples
Example 1: Finding Modular Inverse Using Extended Euclidean Algorithm
Problem: Find the inverse of 3 modulo 11.
Solution: Extended Euclidean Algorithm:\n11 = 3 x 3 + 2\n3 = 1 x 2 + 1\n2 = 2 x 1 + 0\nBack-substitute: 1 = 3 - 1 x 2 = 3 - 1 x (11 - 3 x 3) = 4 x 3 - 1 x 11\nSo x = 4\nVerification: 3 x 4 = 12, 12 mod 11 = 1
Result: 3^(-1) mod 11 = 4 (since 3 x 4 = 12 and 12 mod 11 = 1)
Example 2: No Inverse Exists
Problem: Find the inverse of 6 modulo 9.
Solution: GCD(6, 9) = 3, which is not 1.\nSince 6 and 9 share the common factor 3, no modular inverse exists.\nFor any integer x: 6x mod 9 can only be 0, 3, or 6 (multiples of GCD).\nIt can never equal 1.
Result: No inverse exists because GCD(6, 9) = 3, not 1
Frequently Asked Questions
What is the modular multiplicative inverse?
The modular multiplicative inverse of an integer a modulo m is an integer x such that a times x is congruent to 1 modulo m, written as ax mod m equals 1. In simpler terms, it is the number you multiply a by to get a remainder of 1 when dividing by m. For example, the inverse of 3 modulo 11 is 4, because 3 times 4 equals 12, and 12 mod 11 equals 1. Not every number has a modular inverse; it exists only when a and m are coprime (their GCD is 1). The modular inverse is unique within the range 1 to m-1.
When does the modular inverse exist?
The modular multiplicative inverse of a modulo m exists if and only if a and m are coprime, meaning their greatest common divisor (GCD) is 1. If GCD(a, m) is greater than 1, no inverse exists because no integer x can make a times x leave a remainder of 1 when divided by m. For example, 4 has no inverse modulo 8 because GCD(4, 8) equals 4. However, 4 does have an inverse modulo 7 (which is 2) because GCD(4, 7) equals 1. When m is prime, every integer from 1 to m-1 has a modular inverse, which is why prime moduli are preferred in cryptography.
How does the Extended Euclidean Algorithm find the modular inverse?
The Extended Euclidean Algorithm finds integers x and y such that ax plus my equals GCD(a, m). When GCD(a, m) equals 1, this becomes ax plus my equals 1, which means ax mod m equals 1, so x is the modular inverse of a. The algorithm works by recursively applying the Euclidean algorithm while tracking the coefficients. Starting with the equation a equals q times m plus r, it back-substitutes to express the GCD as a linear combination of a and m. The final x value (taken modulo m to ensure it is positive) is the modular inverse.
How is the modular inverse used in RSA cryptography?
RSA encryption relies heavily on modular inverses. The RSA algorithm selects two large primes p and q, computes n equals p times q, and calculates the totient phi(n) equals (p-1)(q-1). A public exponent e is chosen (commonly 65537), and the private key d is computed as the modular inverse of e modulo phi(n). This means e times d mod phi(n) equals 1. The security of RSA depends on the difficulty of factoring n to find p and q, without which computing the modular inverse to obtain d is computationally infeasible. This makes modular inverses central to modern internet security.
How do you compute modular inverse by brute force?
The brute force method simply tries every integer x from 1 to m-1 and checks whether a times x mod m equals 1. This is conceptually the simplest approach and works correctly for any valid inputs. For example, to find the inverse of 3 mod 7: try 1 (3 mod 7 = 3), try 2 (6 mod 7 = 6), try 3 (9 mod 7 = 2), try 4 (12 mod 7 = 5), try 5 (15 mod 7 = 1) - found it, inverse is 5. However, brute force has time complexity O(m), making it impractical for large moduli used in cryptography where m can have hundreds of digits.
What is a modular inverse table and why is it useful?
A modular inverse table lists the multiplicative inverse of every element in a given modular system. For modulus m, it maps each integer a (where GCD(a, m) equals 1) to its inverse x such that ax mod m equals 1. When m is prime, every non-zero element has an inverse, creating a complete table. These tables are useful for quick lookups in repeated calculations, educational purposes to see patterns in modular arithmetic, and verifying algorithm implementations. For small prime moduli, the table reveals symmetries and structure of the multiplicative group of integers modulo m.
References
Reviewed by Manoj Kumar, Mathematics Educator ยท Editorial policy