Modulo Calculator
Calculate the remainder (modulo) of dividing one number by another.
Did this tool answer your question?
Thanks — this helps us improve the tool.
How to use this tool
- Enter dividend (a) and divisor (b) in the fields above.
- Results update instantly as you type — or click Calculate.
- Read your remainder (a mod b) and the full breakdown beneath it.
The modulo operation (a mod b) returns the remainder after dividing a by b.
Formula
Remainder = a mod b
remainder = a % b
Equivalently: remainder = a − b × floor(a ÷ b)
How it works
This calculator returns the remainder after dividing the dividend (a) by the divisor (b), using the modulo operation. The result is the amount left over once as many whole multiples of b as possible have been subtracted from a. The calculator uses JavaScript’s % operator, which follows truncated division, so results for negative numbers match most programming languages rather than the mathematical modulo convention.
Worked example
- Enter a = 17 (dividend) and b = 5 (divisor).
- 17 ÷ 5 = 3 remainder 2, because 5 × 3 = 15 and 17 − 15 = 2.
- Remainder = 17 mod 5 = 2.
Remainder = 2.
Common mistakes to avoid
- Confusing modulo with integer division; a mod b gives the remainder, not the quotient.
- Expecting modulo to always return a positive value; in many languages -7 % 3 = -1, not 2.
- Using modulo when the divisor is zero; division by zero is undefined and returns an error or NaN.
Key terms
- Modulo
- The operation that returns the remainder after integer division of one number by another.
- Dividend (a)
- The number being divided.
- Divisor (b)
- The number by which the dividend is divided.
- Remainder
- What is left over after dividing as many whole copies of the divisor from the dividend as possible.
- Truncated division
- Division where the quotient is rounded toward zero, which determines the sign of the remainder in most programming languages.
Frequently asked questions
- What is the modulo operation?
- The modulo (%) returns the remainder of a division. For example, 17 mod 5 = 2 because 17 = 3×5 + 2.