Skip to main content

Multiplicative Inverse Modulo Calculator

Free Multiplicative inverse modulo Calculator for arithmetic. Enter values to get step-by-step solutions with formulas and graphs.

Share this calculator

Formula

Find x such that (a * x) mod m = 1

The multiplicative inverse of a modulo m is an integer x where (a times x) is congruent to 1 (mod m). This inverse exists if and only if GCD(a, m) = 1 (a and m are coprime). The Extended Euclidean Algorithm efficiently finds x by computing coefficients in the equation ax + my = GCD(a, m).

Worked Examples

Example 1: Finding Modular Inverse for Cryptography

Problem: Find the multiplicative inverse of 7 modulo 26 (used in affine cipher).

Solution: Extended Euclidean Algorithm:\n26 = 3 x 7 + 5\n7 = 1 x 5 + 2\n5 = 2 x 2 + 1\n2 = 2 x 1 + 0\nBack-substitution:\n1 = 5 - 2 x 2\n1 = 5 - 2(7 - 5) = 3(5) - 2(7)\n1 = 3(26 - 3x7) - 2(7) = 3(26) - 11(7)\nSo x = -11 mod 26 = 15\nVerification: 7 x 15 = 105 = 4 x 26 + 1

Result: Inverse of 7 mod 26 = 15 | Verification: 7 x 15 = 105 = 1 (mod 26)

Example 2: RSA Private Key Calculation

Problem: Find the modular inverse of e = 3 modulo phi(n) = 20.

Solution: Extended Euclidean Algorithm:\n20 = 6 x 3 + 2\n3 = 1 x 2 + 1\n2 = 2 x 1 + 0\nBack-substitution:\n1 = 3 - 1(2)\n1 = 3 - 1(20 - 6x3) = 7(3) - 1(20)\nSo d = 7\nVerification: 3 x 7 = 21 = 1 x 20 + 1\nThe private key d = 7

Result: Inverse of 3 mod 20 = 7 (private key d = 7)

Frequently Asked Questions

What is a multiplicative inverse modulo and when does it exist?

A multiplicative inverse of a number a modulo m is a number x such that (a times x) mod m equals 1. It exists if and only if a and m are coprime, meaning their greatest common divisor (GCD) is 1. For example, the inverse of 3 mod 7 is 5 because 3 times 5 equals 15, and 15 mod 7 equals 1. If a and m share a common factor greater than 1, no inverse exists. For instance, 4 has no inverse mod 6 because GCD(4, 6) = 2. When the modulus m is prime, every number from 1 to m-1 has an inverse, which is one reason prime numbers are so important in cryptography and number theory.

What happens when the modular inverse does not exist?

When GCD(a, m) = g where g is greater than 1, the equation ax is congruent to 1 (mod m) has no solution. However, the equation ax is congruent to b (mod m) may still have solutions if g divides b, in which case there are exactly g solutions modulo m. For example, 4x is congruent to 1 (mod 6) has no solution since GCD(4, 6) = 2 does not divide 1. But 4x is congruent to 2 (mod 6) has two solutions: x = 2 and x = 5. In cryptographic applications, non-existence of an inverse indicates that the chosen parameters are invalid and must be regenerated. Understanding when inverses fail to exist helps in designing robust algorithms and avoiding edge cases in modular arithmetic systems.

What is the difference between modular inverse and regular multiplicative inverse?

The regular multiplicative inverse of a number a is the real number 1/a, which when multiplied by a gives exactly 1. The modular inverse of a modulo m is an integer x in the range [0, m-1] such that (a times x) mod m equals 1. The key differences are: regular inverses always exist for non-zero reals and produce fractions or decimals, while modular inverses only exist when GCD(a, m) = 1 and always produce integers. Regular inverses are unique, while modular inverses are unique only within one complete residue system. For example, the regular inverse of 3 is 0.333..., but the inverse of 3 mod 7 is the integer 5. Both satisfy the fundamental property of undoing multiplication, but in different mathematical structures.

What formula does Multiplicative Inverse Modulo Calculator use?

The formula used is described in the Formula section on this page. It is based on widely accepted standards in the relevant field. If you need a specific reference or citation, the References section provides links to authoritative sources.

How do I interpret the result?

Results are displayed with a label and unit to help you understand the output. Many calculators include a short explanation or classification below the result (for example, a BMI category or risk level). Refer to the worked examples section on this page for real-world context.

How do I get the most accurate result?

Enter values as precisely as possible using the correct units for each field. Check that you have selected the right unit (e.g. kilograms vs pounds, meters vs feet) before calculating. Rounding inputs early can reduce output precision.

References