Modulo Calculator
Calculate a mod b with the quotient and remainder shown step by step. Handles negative numbers with both floored and truncated results. Free, no signup.
About the Modulo Calculator
The modulo operation finds the remainder left over when one number is divided by another: 17 mod 5 = 2, because 5 fits into 17 three times with 2 left over. This free modulo calculator takes any dividend and divisor and instantly shows the modulo result, the quotient, and the division check line in the form dividend = divisor × quotient + remainder.
For negative numbers the answer depends on the convention. Floored modulo (used by Python and most mathematics) always returns a result with the sign of the divisor, so −7 mod 3 = 2. Truncated remainder (used by JavaScript, C and Java's % operator) keeps the sign of the dividend, giving −1 for the same input. This calculator shows both whenever they differ, so programmers moving between languages can see exactly which value their code will produce.
Students meet modulo in number theory and clock arithmetic, while developers use it daily for even/odd checks, wrapping array indexes, hashing and cyclic schedules. Everything runs in your browser with no signup.
How to Use the Modulo Calculator
- 1Enter the dividend (the number being divided).
- 2Enter a non-zero divisor.
- 3Read the modulo result, quotient and remainder instantly.
- 4Check the verification line dividend = divisor × quotient + remainder.
Frequently Asked Questions
How do I calculate 17 mod 5?
Divide 17 by 5 and keep the remainder. 5 × 3 = 15 fits inside 17, leaving 17 − 15 = 2, so 17 mod 5 = 2. The quotient is 3 and the check line reads 17 = 5 × 3 + 2.
What is the modulo of a negative number, like −7 mod 3?
It depends on the convention. Floored modulo (Python, mathematics) gives −7 mod 3 = 2, because −7 = 3 × (−3) + 2. Truncated remainder (JavaScript and C's % operator) gives −1, because −7 = 3 × (−2) − 1. This calculator shows both values whenever they differ.
What is the difference between modulo and remainder?
For positive numbers they are identical. They only diverge for negative inputs: modulo (floored) takes the sign of the divisor while remainder (truncated) takes the sign of the dividend. 10 mod 3 and 10 % 3 are both 1, but −10 mod 3 is 2 while −10 % 3 is −1.
What is modulo used for in real life?
Clock arithmetic is the classic example: 5 hours after 10 o'clock is (10 + 5) mod 12 = 3 o'clock. Programmers use n mod 2 to test even or odd, mod to wrap around array indexes and circular buffers, and modular arithmetic underpins hashing and cryptography.
Can the divisor be zero in a modulo calculation?
No. Division by zero is undefined, so a mod 0 has no value — the calculator asks for a non-zero divisor. Decimals are fine though: 7.5 mod 2 = 1.5, since 2 fits three times leaving 1.5.