Modulo Calculator
Show the math
What Your Result Means
- Remainder (R): The leftover after dividing A by B as many whole times as possible. If R is 0, A is evenly divisible by B.
- Quotient (Q): How many whole times B fits into A, using floor division (always rounds down, even for negative dividends).
- Equation A = B × Q + R: The division identity — it confirms the result: multiply the quotient by the divisor, add the remainder, and you get back to the original dividend.
How This Calculator Works
You enter a dividend (A) and a divisor (B). The tool computes the floor quotient Q = floor(A ÷ B) and the remainder R = A mod B using JavaScript's built-in modulo operator. It then displays the full identity A = B × Q + R. It assumes integer inputs and uses truncated division consistent with most programming languages.
Quick Questions
What happens if the divisor is zero?
Division by zero is undefined in mathematics and produces no result. This calculator returns a dash when B is zero, since there is no valid quotient or remainder.
Does modulo work with negative numbers?
Yes, but the sign of the remainder depends on the language or tool. JavaScript's % operator keeps the sign of the dividend, so −7 % 3 = −1. Other languages (Python, for example) keep the sign of the divisor.
What is modulo used for in programming?
Common uses include checking divisibility (R = 0 means divisible), cycling through arrays or circular buffers, clock arithmetic (hours mod 12), and alternating row colors in a table (row mod 2).
Is modulo the same as remainder?
For positive numbers, yes. For negative numbers, "modulo" and "remainder" can differ depending on convention. This calculator uses JavaScript's remainder operator, which matches the C/Java convention.
Sources
- Wikipedia — Modulo (definition, properties, sign conventions across languages)
- MDN — Remainder Operator (%) (JavaScript implementation details)
Method & review
Estimate only. Results reflect your inputs and standard formulas. Double-check important decisions independently.