Modulo Calculator
Remainder2.0000
Quotient3
Verification5 × 3 + 2 = 17.0000
The modulo operation returns the remainder left after dividing one number by another. This calculator computes that remainder along with the integer quotient and a verification check, using the same sign convention as most programming languages: the remainder takes the sign of the dividend. Modular arithmetic powers clock math, hashing, cryptography, and the common test for whether a number is even or odd.
Formula
remainder = dividend mod divisor; quotient = floor(dividend / divisor); check = divisor * quotient + remainder
- dividend
- The number being divided
- divisor
- The number you divide by (must not be zero)
- remainder
- What is left over; takes the sign of the dividend
- quotient
- The division rounded down (floor) toward negative infinity
How it works
- Enter the dividend (the number being divided) and the divisor (the number you divide by). The divisor must not be zero.
- The calculator computes the remainder using the dividend modulo the divisor, and the quotient as the dividend divided by the divisor rounded down toward negative infinity.
- It also returns a verification value, divisor times quotient plus remainder, which should equal the original dividend, confirming the result is consistent.
Worked examples
Compute 17 mod 5.
- Quotient: floor(17 / 5) = floor(3.4) = 3.
- Remainder: 17 - (5 x 3) = 17 - 15 = 2.
- Verify: 5 x 3 + 2 = 17, matching the dividend.
17 mod 5 = 2, with quotient 3.
Compute -17 mod 5 to see the sign behavior.
- The remainder follows the dividend sign: -17 mod 5 = -2.
- Quotient: floor(-17 / 5) = floor(-3.4) = -4.
- Verify: 5 x (-4) + (-2) = -20 - 2 = -22.
-17 mod 5 = -2, with quotient -4 (the engine uses floor for the quotient).
Frequently asked questions
- What sign does the remainder take for negative numbers?
- The remainder takes the sign of the dividend, following the standard behavior of the modulo operator in languages like JavaScript. So -17 mod 5 gives -2, not 3.
- How is modulo different from regular division?
- Regular division asks how many times one number fits into another; modulo asks what is left over after that. The quotient and the remainder together fully describe the division.
- Why does the calculator show a verification value?
- The check computes divisor times quotient plus remainder, which should equal the original dividend. It confirms the quotient and remainder are consistent with each other and with your input.
- What is modulo used for in real life?
- It is everywhere in computing: testing even or odd (n mod 2), wrapping clock and calendar values, distributing items into buckets via hashing, and the modular arithmetic at the heart of cryptography.