Enter two whole numbers to find the nonnegative modulo remainder and the matching quotient that checks your answer.
Table of contents
How to use our Modulo Calculator
- Enter the whole number being divided in "Number to divide (dividend a)." A plus or minus sign and standard commas, such as 1,234, are allowed.
- Enter the nonzero whole number in "Number to divide by (divisor b)." A negative divisor is valid.
- Click Calculate and read "Remainder (a mod b)" first. This calculator uses a nonnegative Euclidean remainder.
- Sanity-check the answer: "Proof check: divisor x quotient + remainder" should equal the dividend you entered. If a programming remainder appears, use it only for code that truncates division toward zero.

Definitions
Dividend (a): The whole number being divided.
Divisor (b): The nonzero whole number that divides the dividend. Its absolute value sets the possible remainder range.
Euclidean remainder: The main modulo answer. It is at least 0 and less than the absolute value of the divisor.
Whole-number quotient: The integer paired with the Euclidean remainder so dividend = divisor x quotient + remainder.
Programming percent remainder: A remainder based on division rounded toward zero. JavaScript uses this rule for its percent operator, so its result can differ from Euclidean modulo for negative dividends. [1]
Common mistakes and quick fixes
Mistake: Entering a decimal such as 17.5.
Fix: Check Number to divide (dividend a) and then recalculate. Enter a whole number only. This calculator does not calculate decimal modulo.
Mistake: Entering 0 as the divisor.
Fix: Check Number to divide by (divisor b) and then recalculate. Use any nonzero whole number. Modulo by zero is undefined.
Mistake: Typing commas as 1,01.
Fix: Check Number to divide (dividend a) and then recalculate. Use thousands groups of three digits, such as 1,001, or remove the commas.
Mistake: Reading the whole-number quotient as the modulo answer.
Fix: Use "Remainder (a mod b)" as the answer. The quotient is the number of whole divisor groups used in the check.
Mistake: Using a programming percent remainder as the math answer for a negative dividend.
Fix: Check Number to divide (dividend a) and then recalculate. Use the main remainder for this calculator's Euclidean convention. Use the programming value only if it matches the rule used by your programming language.
Limitations & Key Assumptions / Boundary Conditions
- Inputs must be exact whole numbers. Decimals, ranges, formulas, NaN, and Infinity are rejected.
- The divisor cannot be zero. Division and modulo by zero are undefined.
- The main answer uses the Euclidean convention: 0 <= remainder < absolute value of divisor.
- The programming comparison uses truncated remainder behavior. Other programming languages may use a different negative-number rule.
- This calculator handles ordinary integer modulo only. It does not calculate modular powers, greatest common factors, decimal modulo, or congruence equations.
Methodology
Calculation method
The calculator uses exact integer arithmetic. It first uses the positive size of the divisor, then chooses a remainder in the nonnegative Euclidean range.
m = absolute value of b
r = ((a % m) + m) % m
q = (a - r) / b
check = b x q + r
In these formulas, a is the dividend, b is the nonzero divisor, r is the Euclidean remainder, and q is the matching whole-number quotient. The calculator verifies that the check exactly equals a.
Worked example
For a = -17 and b = 5, the Euclidean remainder is 3 and the quotient is -4.
-17 = 5 x (-4) + 3
The proof check rebuilds -17. A truncated programming percent operation gives -17 % 5 = -2 with quotient -3 instead. JavaScript defines its percent operator as a remainder operation using a quotient truncated toward zero. [1]