Free Inverse Modulo Calculator

Enter a and m to calculate the modular inverse

The inverse modulo calculator is a free online tool that handles both multiplicative and additive modular inverses. Whether you need the modular multiplicative inverse for a cryptography assignment or the additive inverse for a number‑theory problem, this calculator provides quick results by leveraging the extended Euclidean algorithm. Available at no cost, it serves students, educators, and professionals who work with modular arithmetic.

Modulo Congruence – The Foundation

Before defining a modular inverse, the notion of congruence must be understood. Let nn be a non‑zero natural number. Two integers aa and bb are said to be congruent modulo nn if they leave the same remainder when divided by nn. Equivalently, the difference a−ba-b is a multiple of nn. This relation is denoted by

a≡b(modn).a \equiv b \pmod{n}.

A pair of examples clarifies the idea:

  • Example 1: 1414 and 9999 are congruent modulo 55 because 99−14=8599-14 = 85 (a multiple of 55). Both numbers also give the remainder 44 when divided by 55.
    14≡99(mod5)14 \equiv 99 \pmod{5}.

  • Example 2: 1414 and 9999 are not congruent modulo 77 because 8585 is not a multiple of 77. Their remainders are 00 and 11 respectively.
    14≢99(mod7)14 \not\equiv 99 \pmod{7}.

A solid grasp of congruence is essential for working with modular inverses.

Additive Modular Inverse

For addition, the identity element is 00. An integer xx is called an additive inverse of aa modulo mm if

a+x≡0(modm).a + x \equiv 0 \pmod{m}.

An additive inverse always exists. To find one manually, start with −a-a and repeatedly add or subtract mm until the result lies in the set {0,1,…,m−1}\{0,1,\dots,m-1\}.

Example 1: Find the additive inverse of 44 modulo 3030.
Numbers of the form −4+30k-4 + 30k are …,−4,26,56,…\dots, -4, 26, 56, \dots.
The value between 00 and 2929 is 2626.
Hence −4≡26(mod30)-4 \equiv 26 \pmod{30}.

Example 2: Find the additive inverse of 4444 modulo 1313.
The sequence −44+13k-44 + 13k gives …,−44,−31,−18,−5,8,22,…\dots, -44, -31, -18, -5, 8, 22, \dots.
The result in {0,…,12}\{0,\dots,12\} is 88.

Multiplicative Modular Inverse

The identity for multiplication is 11. An integer xx is a multiplicative inverse (or modular multiplicative inverse) of aa modulo mm when

a×x≡1(modm).a \times x \equiv 1 \pmod{m}.

Unlike additive inverses, a multiplicative inverse does not always exist. It exists only if aa and mm are coprime (their greatest common divisor is 11). For example, 22 has no multiplicative inverse modulo 66 because for every x∈{1,2,3,4,5}x \in \{1,2,3,4,5\} the product 2x mod 62x \bmod 6 is never 11.

Multiplicative inverses are widely used in cryptography, most notably in the RSA algorithm where they protect sensitive data.

Three Ways to Compute the Multiplicative Inverse

Several methods exist; the choice depends on the modulus size and available tools.

Brute‑Force (Naïve) Method

Try every xx in {1,…,m−1}\{1,\dots,m-1\} until a×x mod m=1a \times x \bmod m = 1. This works for small moduli but becomes impractical for large numbers.

Extended Euclidean Algorithm

Bézout’s identity states that for any integers aa and mm there exist integers xx and yy such that

ax+my=gcd⁡(a,m).a x + m y = \gcd(a,m).

If gcd⁡(a,m)=1\gcd(a,m)=1 (which is required for a multiplicative inverse), the equation becomes ax+my=1a x + m y = 1. Reducing both sides modulo mm gives

ax≡1(modm),a x \equiv 1 \pmod{m},

so the coefficient xx obtained from the extended Euclidean algorithm is the desired multiplicative inverse. This method is efficient, works for any modulus, and is the algorithm implemented in the inverse modulo calculator.

Fermat’s Little Theorem

When the modulus mm is prime and aa is not a multiple of mm, Fermat’s little theorem states

am−1≡1(modm).a^{m-1} \equiv 1 \pmod{m}.

Dividing both sides by aa (which is allowed because aa is invertible modulo a prime) yields

am−2≡a−1(modm).a^{m-2} \equiv a^{-1} \pmod{m}.

Thus am−2 mod ma^{m-2} \bmod m is the multiplicative inverse. This method is fast but limited to prime moduli.

How to Use the Free Inverse Modulo Calculator

Using this online modular inverse calculator is straightforward:

  1. Select the type of inverse you need: multiplicative or additive.
  2. Enter the integer aa and the modulus mm.
  3. Click the calculate button.

The tool immediately returns the modular inverse within the standard range {0,1,…,m−1}\{0,1,\dots,m-1\} (for multiplicative inverses, it excludes 00 because 00 has no multiplicative inverse). A brief explanation of the computation is also displayed, helping you understand how the result was obtained.

Whether you are studying congruence relations, implementing cryptographic algorithms, or simply need a quick calculation, this free inverse modulo calculator online provides a reliable and efficient solution.

FAQ

1. How can I tell whether a multiplicative modular inverse exists for a given a and m?

A multiplicative modular inverse of a modulo m exists if and only if a and m are coprime, i.e., their greatest common divisor (GCD) is 1. If the GCD is greater than 1, the inverse does not exist.

2. What is the difference between an additive inverse and a multiplicative inverse modulo m?

An additive inverse always exists and can be found by adjusting -a with multiples of m until it falls in {0,...,m-1}. A multiplicative inverse exists only when a and m are coprime and requires methods such as the extended Euclidean algorithm or Fermat's little theorem.

3. Why is the extended Euclidean algorithm used to compute modular multiplicative inverses?

The extended Euclidean algorithm finds integers x and y satisfying a·x + m·y = gcd(a,m). When gcd(a,m)=1, the equation reduces modulo m to a·x ≡ 1 (mod m); thus x (mod m) is the multiplicative inverse. This method works for any modulus and is efficient even for large numbers.

4. When can I use Fermat's little theorem to find a modular inverse?

Fermat's little theorem applies only when the modulus m is prime and a is not divisible by m. In that case the inverse is given by a^{m-2} mod m, which can be computed quickly using modular exponentiation.

5. Can this calculator handle large numbers?

Yes, because it uses the extended Euclidean algorithm, whose performance scales well even for large moduli. The tool is designed to work with the integer sizes commonly encountered in cryptography and number theory.

How to Use

  1. Select the type of modular inverse you want to find: Multiplicative or Additive.
  2. Enter the number a in the input field.
  3. Enter the modulus m (must be a positive integer). The result will update automatically.