This modulo calculator computes a mod n the mathematician’s way — remainder always in [0, n) — showing quotient, remainder and the full division equation, plus a congruence tester.
a = qn + r, 0 ≤ r < n — Clock Arithmetic, Formalized
Modulo is division's remainder with a sign convention that keeps it useful: the operation behind clock faces (17:00 = 5 PM), check digits, and hashing. The long-division view lives on our Long Division Calculator. Part of our Math Calculators collection.
Worked Examples (Verified)
- 17 mod 5 = 2 (defaults): 17 = 3 × 5 + 2 — and 27 (the congruence test) is also ≡ 2 (mod 5), so 17 ≡ 27 (mod 5) ✔
- The negative case that splits the world: −7 mod 3 = 2 mathematically (−7 = −3 × 3 + 2), while JavaScript's −7 % 3 = −1 — both printed here, disagreement explained rather than hidden
- 100 mod 7 = 2 — the weekday engine: 100 days from a Wednesday lands on Friday (100 ≡ 2 mod 7)
- Parity is mod 2: every "even/odd" test in programming is a mod-2 remainder check wearing casual clothes
Where Mod Earns Its Keep
- Cryptography: RSA and Diffie–Hellman are modular exponentiation with enormous numbers.
- Check digits: ISBN, credit cards (Luhn) and barcodes validate via mod 10/11 sums.
- Calendars and clocks: mod 7 (weekdays), mod 12/24 (hours), mod 60 (minutes) — cyclic quantities are modulo in uniform.
- Hashing and scheduling: keys mod table-size, round-robin mod n — distribution machinery everywhere.
Related Tools
- Long Division Calculator — quotient & remainder, stepwise
- Big Number Calculator — mod on huge integers exactly
- Math Calculators — the full collection
Frequently Asked Questions
How do you calculate a mod n?
Divide a by n, take the remainder — adjusted so 0 ≤ remainder < n: a = qn + r. 17 mod 5: 17 = 3×5 + 2 → 2. For negatives use floor division: −7 mod 3 = 2 because −7 = (−3)×3 + 2. This calculator shows the equation so the result is auditable.
Why do calculators and languages disagree on negative mod?
Two conventions: floor (mathematics, Python) keeps remainders non-negative; truncation (C, Java, JavaScript's %) keeps the dividend's sign. −7 mod 3 = 2 vs −7 % 3 = −1. Neither is "wrong" — but mixing them in date/cycle code causes classic off-by-sign bugs; know which your context uses.
What does a ≡ b (mod n) mean?
a and b leave the same remainder mod n — equivalently, n divides a − b. 17 ≡ 27 (mod 5) because both leave 2 and 27 − 17 = 10 = 2 × 5. Congruence classes are the integers sorted into n remainder bins, the foundation of modular arithmetic.
What is mod used for in real life?
Clocks (hours mod 12/24), calendars (weekdays mod 7), check digits on cards and ISBNs, hash functions, cryptography (RSA is modular exponentiation), and every cyclic schedule. If a quantity wraps around, a modulo is doing the wrapping.
Can the modulus be larger than the dividend?
Yes: 3 mod 10 = 3 (quotient 0, remainder the number itself). Remainders live in [0, n), so any a < n is its own remainder — which is also why negative small numbers wrap near the top: −1 mod 10 = 9.
Is this modulo calculator free?
Yes — free, instant, no sign-up.