Sumivo · Mathematics
Modulo Calculator
Find a mod n — the remainder of integer division — with the quotient and both remainder conventions, so negative dividends are unambiguous.
01 / inputs
02 / result
A MOD N
2
- Result (Euclidean)
- 2
- Truncated remainder
- 2
- Quotient
- 3
Calculation trace
- 17 = 3 × 5 + 22Division algorithm
- 17 mod 5 = 22Euclidean modulo
How it works
Modulo is the remainder left after integer division. By the division algorithm, for a dividend a and a non-zero modulus n there is a unique quotient q and remainder r with a = q·n + r. This tool reports the Euclidean modulo, where the result is always kept in the range 0 ≤ r < |n|, and it also shows the truncated remainder returned by the % operator in C, Java and JavaScript, whose sign follows the dividend. The two agree when the dividend is non-negative and differ when it is negative — for example −7 mod 3 is 2 in the Euclidean sense but −1 as a truncated remainder.
Assumptions & limits
- Both the dividend and the modulus must be integers; decimals and non-numeric values are rejected.
- The modulus cannot be 0, because division by zero is undefined.
- The main result uses the Euclidean convention (non-negative, 0 ≤ result < |modulus|); the truncated remainder is shown alongside it for programming contexts.
- The quotient is the integer q that satisfies dividend = q × modulus + result exactly.
FAQ
- What does modulo mean?
- The modulo (or “mod”) is the remainder after dividing one integer by another. For 17 mod 5 the quotient is 3 and the remainder is 2, so 17 mod 5 = 2.
- Why does this tool show two different remainders for negative numbers?
- There are two common conventions. The Euclidean modulo always returns a non-negative result (0 ≤ r < |n|), so −7 mod 3 = 2. The truncated remainder used by the % operator in C, Java and JavaScript keeps the sign of the dividend, so −7 % 3 = −1. Both describe the same division; they just place the remainder differently. Python’s % and spreadsheet MOD use the Euclidean result.
- Can the modulus be zero?
- No. Dividing by zero is undefined, so a modulus of 0 is rejected.
- What is modulo used for?
- Wrapping values into a fixed range (clock arithmetic, array indices), checking divisibility (a is divisible by n when a mod n = 0), generating cyclic patterns, hashing, and checksum digits all rely on the modulo operation.
Related calculators
SOURCES
- OpenStax, Rice UniversityPrealgebra 2e ↗
Division with a remainder — the division algorithm a = q·n + r with 0 ≤ r < n
Accessed 2026-09-02
- National Institute of Standards and Technology (NIST)NIST Digital Library of Mathematical Functions (DLMF) ↗
Functions of number theory — congruences and modular arithmetic, a ≡ b (mod n)
Accessed 2026-08-20