Multiplicative Inverse Modulo Calculator

Find the multiplicative inverse of a number in modular arithmetic

Find the multiplicative inverse of a number in modular arithmetic. Enter your base number and modulus to calculate the unique value that makes their product equal to 1 modulo m.

Updated June 2026 · How this works

Example calculation — edit any field to use your own numbers

Worth knowing
How It Works
The formula, explained simply

Imagine you have a lock with 26 positions (like letters in the alphabet) and you turn the dial 7 clicks forward. The multiplicative inverse tells you exactly how many clicks backward will bring you to the starting position, but not by simple subtraction — by a multiplicative relationship. If turning 7 clicks is your encoding step, then turning the inverse number of clicks (15 in this case) will decode it perfectly.

The extended Euclidean algorithm works like finding the perfect counterbalance. It systematically breaks down the relationship between your two numbers, working backward through their remainders until it discovers the exact coefficient that makes their product equal to 1 modulo your chosen number. This process guarantees finding the unique inverse when one exists.

The mathematics relies on Bézout's identity: for any two integers a and m, there exist integers x and y such that ax + my = gcd(a,m). When a and m are coprime (gcd equals 1), the coefficient x becomes our multiplicative inverse, representing the exact value needed to make the modular multiplication equal 1.

When To Use This
Right tool, right situation

Use multiplicative inverse calculations when implementing cryptographic algorithms, particularly RSA encryption where finding the decryption exponent requires computing the multiplicative inverse of the encryption exponent modulo φ(n). The algorithm is also essential for solving linear congruences of the form ax ≡ b (mod m), where you multiply both sides by the inverse of a.

In computer science, multiplicative inverses appear in hash function design, error-correcting codes, and algorithms for working with finite fields. They are fundamental in abstract algebra when performing division operations in modular arithmetic systems, since division by a is equivalent to multiplication by its inverse.

Avoid using this tool when working with non-coprime numbers or when simple modular arithmetic (without division) suffices for your problem. For basic modular addition or subtraction, multiplicative inverses are unnecessary. Also, when working with real numbers rather than integers, standard reciprocals are more appropriate than modular inverses.

Common Mistakes
Why results sometimes look wrong

The most common mistake is attempting to find multiplicative inverses for numbers that are not coprime with the modulus. Students often assume every number has an inverse, but 6 has no multiplicative inverse modulo 9 because gcd(6,9) = 3 ≠ 1. Always check that the GCD equals 1 before proceeding with inverse calculations.

Another frequent error occurs when handling negative intermediate results from the extended Euclidean algorithm. The algorithm may produce a negative coefficient, which students sometimes report as the final answer. However, multiplicative inverses are conventionally expressed as positive integers between 1 and m-1, requiring addition of the modulus to negative results.

Many learners also confuse multiplicative inverses with additive inverses or simple reciprocals. The multiplicative inverse of 7 modulo 26 is not 1/7 or -7, but rather the specific integer (15) that makes 7 × 15 ≡ 1 (mod 26). This confusion stems from mixing standard arithmetic with modular arithmetic properties.

The Math
Worked examples and deeper derivation

The multiplicative inverse of a modulo m exists if and only if gcd(a,m) = 1. The extended Euclidean algorithm finds this inverse by solving the equation ax + my = 1, where x is the multiplicative inverse we seek. The algorithm works by repeatedly applying the division algorithm: at each step, it expresses the remainder as a linear combination of the previous two values.

Starting with a and m, the algorithm computes a sequence of equations: m = q₁a + r₁, a = q₂r₁ + r₂, and so forth, until reaching a remainder of 0. The last non-zero remainder is the GCD. By working backward through these equations, we express the GCD as a linear combination of the original numbers, giving us the Bézout coefficients.

When the GCD equals 1, the coefficient of a in this linear combination is the multiplicative inverse. If this coefficient is negative, we add m to obtain the canonical representative between 0 and m-1. The verification step confirms that a × inverse ≡ 1 (mod m), proving the calculation is correct.

Caesar Cipher Key Generation
Base number: 7, Modulus: 26 (alphabet size)
The multiplicative inverse is 15. This means 7 × 15 ≡ 1 (mod 26), making 15 the decryption key for a multiplicative cipher with encryption key 7.
Fraction Simplification in Finite Fields
Base number: 3, Modulus: 11
The multiplicative inverse is 4. In the finite field Z₁₁, dividing by 3 is equivalent to multiplying by 4, since 3 × 4 ≡ 1 (mod 11).
RSA Cryptography Component
Base number: 5, Modulus: 17
The multiplicative inverse is 7. This relationship (5 × 7 ≡ 1 mod 17) is fundamental in RSA key generation where we need inverse relationships for encryption and decryption exponents.
Expert Unlock
The thing most explanations skip

The extended Euclidean algorithm's efficiency breaks down for extremely large numbers due to the recursive nature of the computation. For cryptographic applications with 2048-bit integers, optimized implementations use binary GCD algorithms or Montgomery reduction techniques to maintain practical computation times while preserving mathematical accuracy.

What makes two numbers coprime in modular arithmetic?

Why does no multiplicative inverse exist for some numbers?
A multiplicative inverse exists only when the base number and modulus are coprime, meaning their greatest common divisor (GCD) equals 1. If they share a common factor, no inverse exists because their product can never equal 1 modulo m.
How is the extended Euclidean algorithm different from regular GCD?
The extended Euclidean algorithm not only finds the GCD of two numbers but also finds the coefficients (Bézout coefficients) that satisfy the equation ax + by = gcd(a,b). These coefficients give us the multiplicative inverse when the GCD equals 1.
What happens if I get a negative multiplicative inverse?
Negative results are automatically adjusted by adding the modulus to get the equivalent positive value. In modular arithmetic, -3 ≡ 5 (mod 8), so we always return the positive representative between 0 and m-1.

Need something this doesn't cover?

Suggest a tool — we'll build it →