Modular Inverse Calculator

Find the modular multiplicative inverse of a number mod m, with full extended Euclidean algorithm step-by-step.

Use the Modular Inverse Calculator

Inputs

Any integer (positive or negative).

Must be an integer greater than 1.

Quick Examples

Enter values and click Calculate.

Copied!

Summary

Find the modular multiplicative inverse of a number mod m, with full extended Euclidean algorithm step-by-step.

How it works

  1. Enter the integer a whose inverse you want to find.
  2. Enter the modulus m (must be greater than 1).
  3. Click Calculate to run the extended Euclidean algorithm.
  4. The tool checks that gcd(a, m) = 1 — a necessary condition for the inverse to exist.
  5. Each step of the back-substitution is shown so you can follow the full working.
  6. The final result x is the unique inverse in the range [0, m − 1].

Use cases

  • Solving linear congruences in number theory coursework.
  • Computing private keys and inverses in RSA cryptography.
  • Working through Diffie-Hellman key exchange problems.
  • Checking homework answers for modular arithmetic assignments.
  • Computing modular division (a / b mod m = a · b⁻¹ mod m).
  • Understanding the extended Euclidean algorithm step by step.
  • Preparing for competitive programming contests involving number theory.
  • Verifying implementations of modular arithmetic in code.

Frequently Asked Questions

Last updated: 2026-09-22 · Reviewed by Nham Vu