Modulo Calculator
The modulo operation finds the remainder left after dividing one integer by another as many whole times as possible. Written as a mod b, it answers the question: when you divide a by b using only whole-number division, how much is left over? For example, 17 mod 5 equals 2 because 5 fits into 17 three whole times (3 times 5 = 15) and a remainder of 2 is left. Despite its simplicity, modulo is one of the most used operations in mathematics and computing. It is the standard way to test divisibility: if a mod b equals zero, then a is exactly divisible by b. It detects even and odd numbers: a mod 2 equals 0 for even, 1 for odd. It wraps values around cycles, such as converting a total number of minutes into hours and remaining minutes, or cycling through positions in an array. This calculator returns the remainder, the quotient (how many whole times b fits into a), and the full equation showing the relationship between dividend, divisor, quotient, and remainder. It also checks whether a is exactly divisible by b. This calculator uses the mathematical flooring convention: the quotient is always rounded toward negative infinity, meaning the remainder is always non-negative when the divisor is positive. This may differ from the truncating convention used in some programming languages for negative inputs. Enter your dividend and divisor, both integers, to see the result update immediately. The divisor cannot be zero since division by zero is undefined.
Uses the mathematical flooring convention: remainder is non-negative for a positive divisor. Divisor cannot be zero.
How it works
The calculator rounds the quotient toward negative infinity using Math.floor rather than truncating toward zero, which ensures the remainder always has the same sign as the divisor. For a positive divisor, this gives a non-negative remainder in the range from 0 to b minus 1. The full equation a = quotient times b plus remainder verifies the result. If the remainder is zero, a is exactly divisible by b.
Worked example
Enter a = 17 and b = 5. The divisor 5 fits into 17 a total of 3 whole times (3 times 5 = 15). The remainder is 17 minus 15 = 2. The full equation is 17 = 3 times 5 + 2. Because the remainder is not zero, 17 is not exactly divisible by 5. These values match the defaults pre-filled in the calculator above.
Related calculators
- Rounding Calculator: round a number to decimal places or the nearest multiple.
- Significant Figures Calculator: round to the correct number of significant figures.
- Decimal to Fraction Calculator: convert a decimal to its simplest fraction.
- Percent Error Calculator: measure deviation from a true value.