Modulo Calculator
Modulo Calculator
Enter a dividend and a divisor. This calculates the modulo — the remainder left after dividing the dividend by the divisor — using the mathematical convention where the remainder is always non-negative for a positive divisor, even when the dividend is negative.
This matters most with negative numbers: −17 mod 5 comes out to 3, not −2, because this calculator uses the mathematical (Euclidean) definition of modulo rather than the "truncating" behavior some programming languages default to for the % operator. Modulo arithmetic underlies clock and calendar calculations (wrapping hours or days around a cycle), hashing and checksum algorithms, and any situation where a value needs to "wrap around" after reaching a fixed limit.
- Formula: a mod n = a − n × floor(a ÷ n), which always gives a remainder between 0 and n−1 for a positive divisor n.
- Negative dividends still give a non-negative remainder: −17 mod 5 = 3, not −2, because this calculator uses the mathematical (Euclidean) definition of modulo rather than the "truncating" version some programming languages use for the % operator.
- Common uses: checking for even/odd numbers (n mod 2), wrapping values around a fixed range (like clock arithmetic), and cryptography.
Why does −17 mod 5 equal 3 and not −2?
Under the mathematical definition of modulo, the result is always in the range [0, n), so instead of stopping at the first negative remainder, the calculator keeps adding the divisor until the result lands in that non-negative range: −17 + 5 + 5 + 5 = −2, then one more 5 gives 3.
How is this different from the % operator in programming languages like JavaScript or C?
Many languages' % operator truncates toward zero, which can give a negative remainder for a negative dividend — this calculator instead always returns a non-negative remainder for a positive divisor, matching the mathematical convention.
Modulo Calculator


Enter a dividend and a divisor. This calculates the modulo — the remainder left after dividing the dividend by the divisor — using the mathematical convention where the remainder is always non-negative for a positive divisor, even when the dividend is negative.
This matters most with negative numbers: −17 mod 5 comes out to 3, not −2, because this calculator uses the mathematical (Euclidean) definition of modulo rather than the "truncating" behavior some programming languages default to for the % operator. Modulo arithmetic underlies clock and calendar calculations (wrapping hours or days around a cycle), hashing and checksum algorithms, and any situation where a value needs to "wrap around" after reaching a fixed limit.

- Formula: a mod n = a − n × floor(a ÷ n), which always gives a remainder between 0 and n−1 for a positive divisor n.
- Negative dividends still give a non-negative remainder: −17 mod 5 = 3, not −2, because this calculator uses the mathematical (Euclidean) definition of modulo rather than the "truncating" version some programming languages use for the % operator.
- Common uses: checking for even/odd numbers (n mod 2), wrapping values around a fixed range (like clock arithmetic), and cryptography.
Why does −17 mod 5 equal 3 and not −2?
Under the mathematical definition of modulo, the result is always in the range [0, n), so instead of stopping at the first negative remainder, the calculator keeps adding the divisor until the result lands in that non-negative range: −17 + 5 + 5 + 5 = −2, then one more 5 gives 3.
How is this different from the % operator in programming languages like JavaScript or C?
Many languages' % operator truncates toward zero, which can give a negative remainder for a negative dividend — this calculator instead always returns a non-negative remainder for a positive divisor, matching the mathematical convention.
