The modulo operation is clock arithmetic: 15:00 is 3 o’clock because 15 mod 12 = 3. It is used to find days of the week, check digits, cycle through arrays, and in hashing and cryptography.
How to use the Modulo Calculator
- x (dividend)
- y (divisor)
Results update as you type, and everything is calculated in your browser.
How it works
The quotient is rounded down (floored), so the remainder always has the same sign as the divisor. Programming languages that truncate (C, Java, JavaScript %) give a different answer for negative numbers; both are shown.
Inputs explained
| Field | What to enter |
|---|---|
| x (dividend) | A number |
| y (divisor) | A number |
What each result means
- r = x mod y = mod([x (dividend)], [y (divisor)])
- Quotient q = ⌊x / y⌋ = floor([x (dividend)]÷[y (divisor)])
- Truncated remainder (C / JavaScript %) = [x (dividend)] – [y (divisor)]×trunc([x (dividend)]÷[y (divisor)])
Example values
How the main result changes when x changes and everything else stays at the example values above:
| x (dividend) | r = x mod y |
|---|---|
| 125 | 6 |
| 187.5 | 5.5 |
| 250 | 5 |
| 312.5 | 4.5 |
| 375 | 4 |
| 500 | 3 |
Formula
x mod y = x − y·⌊x / y⌋
x = q·y + r
Worked example
Inputs: x (dividend): 250; y (divisor): 7.
Results: r = x mod y = 5; Quotient q = ⌊x / y⌋ = 35; Truncated remainder (C / JavaScript %) = 5.
Key terms
- Modulo
- The remainder after division.
- Congruent
- a ≡ b (mod n) when a and b leave the same remainder.
Frequently asked questions
What is 250 mod 7?
5, because 250 = 35 × 7 + 5.
What is −7 mod 3?
2 with the mathematical definition (−7 = −3 × 3 + 2); −1 with truncation.
Can I use decimals?
Yes: 7.5 mod 2 = 1.5.
What is x mod 1?
The fractional part of x.