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
- a mod n: remainder when a is divided by n (always 0 ≤ result < n)
- (a+b) mod n = ((a mod n) + (b mod n)) mod n
- (a×b) mod n = ((a mod n) × (b mod n)) mod n
- Modular inverse: find x such that a×x ≡ 1 (mod n), requires gcd(a,n)=1
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.