Skip to content
UnitFormula

The modulo operation, written a mod n, gives the remainder left over when a is divided by n. Divide a by n, take the whole-number part (the quotient), multiply it back by n, and subtract: what remains is the modulo. For example, 17 mod 5 is 2, because 17 = 5 × 3 + 2. Enter a dividend and divisor and the calculator returns the remainder and the quotient.

Modulo Calculator — remainder of a division

The remainder of 17 divided by 5.

Remainder (a mod n)2
Quotient
3

Quick examples

How it's calculated

  1. Subtract the largest multiple of the divisor that fits17=5×3+217 = 5 \times 3 + 2
    dividend
    = 17
    divisor
    = 5
    2
Remainder (a mod n)2

How it works

Modulo is the remainder of a division. To compute a mod n, per Wolfram MathWorld, use the relationship with the floor function:

a mod n = a − n × ⌊a ÷ n⌋

In words: divide a by n and round down to a whole number — that is the quotient. Multiply the quotient by n and subtract it from a; what is left is the remainder. For a positive divisor the remainder is always between 0 and n − 1.

For 17 mod 5, dividing 17 by 5 gives 3.4, which rounds down to a quotient of 3. Then 17 − 5 × 3 = 2, so the remainder is 2. This matches the everyday check 17 = 5 × 3 + 2.

Because it uses the floor, a negative dividend still gives a non-negative remainder: −17 mod 5 is 3, since ⌊−17 ÷ 5⌋ = −4 and −17 − 5 × (−4) = 3. Modulo underpins clock arithmetic, odd/even tests, cycling through lists, and hashing.

Worked example

Take 17 mod 5. Dividing 17 by 5 gives 3.4, so the quotient is 3. Multiply back: 5 × 3 = 15, and 17 − 15 = 2. So 17 mod 5 is 2, confirming 17 = 5 × 3 + 2.

Frequently asked questions

What does "mod" mean?

"Mod" is short for modulo — the remainder after dividing one number by another. For example, 17 mod 5 = 2 means dividing 17 by 5 leaves a remainder of 2.

How do you calculate a modulo?

Divide the dividend by the divisor and round down to get the quotient, multiply the quotient by the divisor, then subtract from the dividend: a − n × ⌊a ÷ n⌋. For 17 and 5, that is 17 − 5 × 3 = 2.

What is the difference between the remainder and the quotient?

The quotient is how many whole times the divisor fits into the dividend; the remainder is what is left over. For 17 ÷ 5, the quotient is 3 and the remainder is 2.

How does modulo handle negative numbers?

This calculator uses the floor-based definition, so the remainder is non-negative for a positive divisor. For example, −17 mod 5 is 3, not −2. Some programming languages instead return −2, so check your language's convention.

What happens if the divisor is zero?

Dividing by zero is undefined, so a mod 0 has no result. The divisor must be a nonzero number.

Where is modulo used?

It appears everywhere from clock and calendar arithmetic (26 mod 12 = 2 o'clock) to checking whether a number is even (n mod 2), wrapping around lists, and computing checksums and hash codes.

How we know this is right

Last reviewed
Aug 8, 2026
Precision
Rounded to 0 decimal places.
Read our methodology

Sources