Inverse Modulo

Find the modular multiplicative and additive inverse modulo m for any integers a and m. Free online number theory calculator using the extended Euclidean algorithm with instant step results.

Calculate

About This Calculator

About the Inverse Modulo Calculator

The Inverse Modulo Calculator helps you find both the multiplicative inverse and additive inverse of any integer a modulo m. This tool is essential for students studying number theory, cryptography professionals working with encryption algorithms, and anyone dealing with modular arithmetic problems in mathematics or computer science.

How It Works

This calculator uses the extended Euclidean algorithm to efficiently compute the modular multiplicative inverse. The multiplicative inverse x satisfies a x x ≡ 1 (mod m), and exists only when a and m are coprime (gcd(a, m) = 1). The additive inverse, which always exists, satisfies a + x ≡ 0 (mod m) and equals (m - a mod m) mod m. Both results are displayed in the range 0 to m-1.

Applications of Modular Inverses

Modular inverses are fundamental in cryptography, particularly in RSA encryption which secures online transactions, emails, and sensitive data worldwide. They are also used in solving systems of congruences via the Chinese Remainder Theorem, computing division in modular arithmetic, error-correcting codes, checksum algorithms like the Luhn algorithm, and hash functions in computer science.

The multiplicative inverse is the more commonly referenced type in cryptography. For example, RSA key generation relies on finding the modular multiplicative inverse of the public exponent e modulo φ(n) to derive the private key. The additive inverse is used in clock arithmetic and solving linear modular equations.

Example

Find the inverse modulo of a = 3 and m = 7: The multiplicative inverse of 3 modulo 7 is 5 because (3 x 5) mod 7 = 15 mod 7 = 1. The additive inverse of 3 modulo 7 is 4 because (3 + 4) mod 7 = 0.

Frequently Asked Questions

What is the difference between multiplicative and additive inverse modulo?

The multiplicative inverse of a modulo m is a number x such that (a x x) ≡ 1 (mod m). It exists only when a and m are coprime. The additive inverse is a number x such that (a + x) ≡ 0 (mod m), and it always exists for any integers a and m.

When does the multiplicative modular inverse exist?

The multiplicative modular inverse of a modulo m exists if and only if a and m are coprime, meaning their greatest common divisor (GCD) is 1. For example, 3 has a multiplicative inverse modulo 7 because gcd(3, 7) = 1, but 2 has no inverse modulo 4 because gcd(2, 4) = 2.

How is the multiplicative inverse computed?

The calculator uses the extended Euclidean algorithm, which finds integers x and y such that a x x + m x y = gcd(a, m). When gcd(a, m) = 1, the value x reduced modulo m gives the multiplicative inverse in the range 0 to m-1.

What is the additive inverse modulo?

The additive inverse of a modulo m is the number x in the range 0 to m-1 such that (a + x) mod m = 0. It is computed as (m - a mod m) mod m. For example, the additive inverse of 4 modulo 7 is 3 because (4 + 3) mod 7 = 0.

Why is the modular inverse important?

Modular multiplicative inverses are essential in cryptography, particularly in RSA encryption which secures credit card transactions and sensitive data. They are also used in solving modular equations, checksum algorithms, and computer science applications like hash functions.

Can I calculate the inverse for negative numbers?

Yes. The calculator handles negative values for a. The result is always given as a positive number between 0 and m-1. For example, the multiplicative inverse of -3 modulo 7 equals the inverse of 4 modulo 7 since -3 ≡ 4 (mod 7).

What happens if a and m are not coprime?

When gcd(a, m) ≠ 1, the multiplicative inverse does not exist. The calculator will display 'No inverse (not coprime)' for the multiplicative inverse result. The additive inverse is still computed as it always exists.

Is this tool free to use?

Yes, all calculators on Calculy are completely free to use with no registration or login required.