Understand the method
What does the modulo and remainder calculation mean?
Modulo returns the remainder after integer division, chosen to be nonnegative. Every integer a can be written as a = bq + r with 0 ≤ r < b, which fixes r uniquely even when a is negative.
When to use it
Use it for repeating cycles such as clock times, calendar weekdays, check digits, and hash buckets.
Formula
In plain text: a = bq + r, 0 ≤ r < b
Variables and units
| Symbol | Meaning |
|---|---|
| a | the dividend |
| b | the divisor, nonzero |
| q | the quotient |
| r | the remainder, with 0 ≤ r < b |
How to use the calculator
- Enter each known value in its labeled field.
- Select the answer precision you want.
- Choose Calculate answer to see the result and working.
Worked example
−17 mod 5 equals 3 because −17 = 5(−4) + 3. The quotient rounds toward negative infinity so the remainder stays nonnegative, unlike some programming languages.
Common mistakes
- A negative dividend still yields a nonnegative remainder here.
- The divisor cannot be zero.
- Modulo is not the same as the fractional part of a division.
Interpret the result
Two integers with the same remainder are congruent modulo b, meaning their difference is a whole multiple of b.