InfyCalculator
➗

Modulo Remainder Calculator

Compute a mod n — the remainder after division — with both the truncated and floored (always non-negative) result.

Dividend (a)
Divisor / modulus (n)
Loading calculator…

How it works

a mod n = a − n × trunc(a ÷ n) · floored: ((a mod n) + n) mod n

The modulo operation returns what is left over after dividing one number by another. Multiply the whole-number quotient by the divisor and subtract from the dividend to get the remainder. Languages differ on negative inputs: the truncated remainder takes the sign of the dividend, while the "floored" remainder is always non-negative for a positive modulus — this tool shows both when they differ.

Worked example

17 mod 5: 17 divided by 5 is 3 with 2 left over, since 5 × 3 = 15 and 17 − 15 = 2. So 17 mod 5 = 2.

Frequently asked questions

What does modulo mean?

Modulo (or mod) gives the remainder of a division. 17 mod 5 = 2 because 5 goes into 17 three times with 2 remaining.

What is the modulo of a negative number?

It depends on the convention. In JavaScript-style truncated division -17 mod 5 = -3, while the floored convention gives 3. Both are correct answers to different definitions, so this tool reports both when they differ.

What is modulo used for?

It is everywhere in computing and math: wrapping clock arithmetic, checking even or odd (n mod 2), cycling through array indices, and testing divisibility (a mod n = 0 means n divides a).

Related calculators

This calculator is for educational purposes. Double-check important results before acting on them.