🔢Modular Arithmetic Calculator

Calculate mod operation and modular inverse

How to Use the Modular Arithmetic Calculator

Enter values for a, b, and modulus n to instantly compute a mod n, modular addition, multiplication, and the modular inverse of a. The modular inverse exists only when gcd(a, n) = 1 — a fundamental requirement in RSA cryptography.

Key Formulas

Frequently Asked Questions

When does the modular inverse not exist?

When gcd(a, n) ≠ 1. For instance, a=4 and n=6 share a common factor of 2, so no modular inverse exists. The calculator displays a clear message in this case.

How are negative numbers handled?

Following the mathematical definition, the result is always non-negative: −7 mod 3 = 2, since −7 = 3×(−3) + 2.

Where is modular arithmetic applied?

RSA encryption, hash functions, calendar calculations (e.g., day of week), ISBN/EAN checksums, and many areas of cryptography and theoretical computer science.