Modulo Calculator
Remainder, quotient, and check for integer division A mod N.
What it does
Modulo answers the leftover question after division. Seventeen cookies across five bags fill three full bags with two cookies spare, so 17 mod 5 is 2. The tool above prints that remainder with the quotient and a multiply back check.
The default divides 17 by 5 for quotient 3 remainder 2, verified as 3 x 5 + 2 = 17. The same pattern powers clocks, calendars, and code: even numbers are 0 mod 2, week cycles run mod 7, and hash tables scatter keys by mod table size.
Negatives follow the floored convention here, matching standard math texts. Minus 17 mod 5 is 3, because -4 x 5 + 3 rebuilds -17 with a non-negative remainder. Some programming languages return -2 instead, which this page deliberately avoids so remainders stay inside 0 to N minus 1.
Zero divisors have no answer in any convention, and the tool says so instead of guessing. Huge values up to a trillion stay exact; past that, floating point starts lying about units, so the page stops first.
How to use
- Type the whole dividend A.
- Type the whole non-zero divisor N.
- Read the remainder first.
- Read the quotient beside it.
- Multiply back with the check line to confirm.
Formula
- A
- Dividend being split.
- N
- Divisor; absolute value sets the range.
- r
- Remainder from 0 to N minus 1.
Floored division throughout, per standard number theory texts. Truncated remainders from some languages differ on negatives and are not used here.
Worked example
Example: 17 mod 5
Defaults: A 17, N 5.
- Divide: 17 / 5 = 3.4, floor to 3.
- Multiply: 3 x 5 = 15.
- Subtract: 17 minus 15 = 2.
- Range check: 2 sits inside 0 to 4.
- Tool shows 2, 3 r 2, 3 x 5 + 2 = 17.
Reference table
| Division | Quotient | Remainder |
|---|---|---|
| 7 mod 3 | 2 r 1 | 1 |
| 10 mod 4 | 2 r 2 | 2 |
| 15 mod 5 | 3 r 0 | 0 |
| 23 mod 7 | 3 r 2 | 2 |
Limits
- Whole numbers only; decimals round first.
- Non-zero divisors; zero has no remainder.
- Magnitudes cap at a trillion for exactness.
- One convention shown; code % may differ on negatives.
Common mistakes
- Dividing by zero and expecting zero.
- Reading the quotient as the answer.
- Assuming negatives stay negative.
- Mixing mod with percent of amounts.
- Trusting float division past a trillion.
Try it yourself
Quick checks. Answers sit tucked under each question.
100 mod 7?
14 x 7 + 2 = 100, so remainder 2.
20 mod 6?
3 x 6 + 2 = 20, so remainder 2.
-17 mod 5?
-4 x 5 + 3 = -17, so remainder 3.
Questions
What is 17 mod 5?
2, since 3 x 5 + 2 = 17.
What about negative numbers?
This page floors, so -17 mod 5 is 3, always 0 or more.
Why do languages disagree?
Many truncate toward zero; math texts floor toward minus infinity.
Modulo or percent?
Modulo here is remainder math, not hundredths of an amount.
What is anything mod 1?
Always 0, since 1 divides everything evenly.
Where is modulo used?
Clocks, calendars, checksums, hashing, and ciphers.