The modulo operation, written a mod b, gives the remainder after dividing a (the dividend) by b (the divisor). It's the leftover once you remove every whole multiple of b: 17 mod 5 = 2 because 17 = 3 × 5 + 2. For positive numbers it equals the ordinary remainder; for negatives, conventions differ, so this calculator shows both the truncated remainder and the always-positive floored modulo, plus the quotient.
Reviewed: June 20, 2026 · Author: Naveen P N, Founder — AI Calculator · Verified against: the division algorithm a = qb + r, recomputed in code.
How modulo works
Every division splits into a whole-number quotient and a leftover remainder smaller than the divisor. The modulo is that remainder. With positive inputs it's unambiguous, but a negative dividend forces a choice: keep the sign of the dividend (truncated remainder, common in programming) or always return a non-negative value (floored or Euclidean modulo, common in maths). Both satisfy a = qb + r with different q.
Worked example — 17 mod 5 and −7 mod 3
Scenario: a positive case and a negative one.
17 mod 5 = 2: five goes into seventeen three times (15), leaving 2. For negatives, −7 mod 3 is −1 under the truncated rule (matching −7 = −2 × 3 + (−1)) but 2 under the floored rule (−7 = −3 × 3 + 2). Both are "correct" — they just use a different quotient. The calculator reports both so you can match whatever language or textbook you're following.
Frequently Asked Questions
The remainder after division. In a mod b, a is the dividend, b the divisor. 17 mod 5 = 2; 20 mod 5 = 0.
remainder = a − (quotient × b). 100 ÷ 7 = 14 r 2, since 14 × 7 = 98 and 100 − 98 = 2.
Truncated keeps the dividend's sign (−7 % 3 = −1); floored is always ≥ 0 (−7 mod 3 = 2). Both are shown.
Even/odd (n mod 2), divisibility, clocks (mod 12), days (mod 7), hashing, wrapping indices, cryptography.
For positives, identical. They differ only with negatives — "remainder" truncates, "modulo" often floors. 17 & 5 → 2 either way.