Skip to main content
🔢 Number Theory

Modulo Calculator

Find the remainder of a ÷ b — the modulo a mod b — along with the integer quotient and the always-positive floored modulo for negative numbers, with the working shown.

a mod b remainder
Integer quotient
Positive (floored) mod
Handles negatives
100% Free
🔢 Open All Math Calculators 📖 Read the Guide

Modulo — Quick answer

a mod b is the remainder left after dividing a by b.

a = quotient × b + remainder  ·  remainder = a − ⌊a/b⌋ × b

Worked example: 17 mod 5 = 2 (17 = 3×5 + 2) · 100 mod 7 = 2 · 20 mod 5 = 0.

Modulo quick reference

a mod bQuotientRemainder
17 mod 532
100 mod 7142
20 mod 540
−7 mod 3−32 (floored)

For positives, remainder and modulo agree; negatives depend on the convention.

🔢 Modulo Calculator

Enter the dividend (a) and the divisor (b). The divisor can't be zero.

Remainder (a % b)
Positive modulo (floored)
Integer quotient
Divisible?

ℹ️ For positive numbers, the remainder and the positive modulo are the same. They differ only when the dividend is negative — the calculator shows both.

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

Division identity
a = quotient × b + remainder
Remainder
r = a − (quotient × b)
Floored modulo
((a mod b) + b) mod b  (always ≥ 0)

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
17 ÷ 5 = 3 remainder 2 → 3 × 5 + 2 = 17
−7 mod 3 (truncated)
−7 % 3 = −1 (sign of dividend)
−7 mod 3 (floored)
((−1) + 3) mod 3 = 2 (always positive)

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

What does modulo mean?

The remainder after division. In a mod b, a is the dividend, b the divisor. 17 mod 5 = 2; 20 mod 5 = 0.

How do you calculate a mod b?

remainder = a − (quotient × b). 100 ÷ 7 = 14 r 2, since 14 × 7 = 98 and 100 − 98 = 2.

How does modulo work with negatives?

Truncated keeps the dividend's sign (−7 % 3 = −1); floored is always ≥ 0 (−7 mod 3 = 2). Both are shown.

What is modulo used for?

Even/odd (n mod 2), divisibility, clocks (mod 12), days (mod 7), hashing, wrapping indices, cryptography.

Is modulo the same as remainder?

For positives, identical. They differ only with negatives — "remainder" truncates, "modulo" often floors. 17 & 5 → 2 either way.

Need more math tools?

Explore GCD/LCM, prime numbers, long division, fractions and more across the AI Calculator math suite.

🔢 Open Math Calculators — Free

No registration required · 350+ calculators · PDF report export