Modulo Calculator
Find a mod b — the remainder when a is divided by b — along with the integer quotient and the always-positive (Euclidean) modulo for negatives.
Enter a dividend (a) and a divisor (b) to find the remainder of a ÷ b and the integer quotient.
Check: 5 × 3 + 2 = 17.
Quick answer
The modulo operation a mod b gives the remainder after dividing a by b. For 17 mod 5, 17 = 5 × 3 + 2, so the remainder is 2 and the quotient is 3. This calculator shows the remainder, the quotient, and an always-positive Euclidean result for negative dividends.
Formula & method
The tool computes the truncated quotient ⌊a ÷ b⌋ toward zero and the remainder a − quotient × b, which is exactly JavaScript's % operator and takes the sign of a. It also reports the Euclidean modulo ((a % b) + |b|) % |b|, always in the range 0 to |b| − 1, and verifies b × quotient + remainder = a.
Examples
- Input
- 17 mod 5
- Result
- 2
- Why
- 17 = 5 × 3 + 2, so the quotient is 3 and the remainder is 2.
- Input
- 100 mod 7
- Result
- 2
- Why
- 100 = 7 × 14 + 2, so the remainder is 2.
- Input
- −17 mod 5
- Result
- −2 (Euclidean 3)
- Why
- JS-style remainder takes the sign of a: −17 = 5 × (−3) + (−2). The always-positive form is 3.
When to use this tool
- Checking whether a number is even, odd, or divisible by another.
- Wrapping values around a cycle — clock hours, days of the week, array indices.
- Extracting the last digit (n mod 10) or grouping items into buckets.
Common mistakes
- Assuming the remainder is always positive — with a negative dividend the truncated remainder is negative.
- Using a divisor of 0, which is undefined (division by zero).
- Confusing the quotient (whole number of times b fits into a) with the remainder (what's left over).
Frequently asked questions
What does a mod b mean?
It is the remainder when a is divided by b. For 17 mod 5 the remainder is 2, because 17 = 5 × 3 + 2.
What is the quotient?
The whole number of times the divisor fits into the dividend, truncated toward zero. For 17 ÷ 5 the quotient is 3.
Why is the remainder negative sometimes?
When the dividend is negative, the standard (truncated) remainder takes the sign of the dividend. The tool also shows an always-positive Euclidean value.
What is the Euclidean modulo?
A version of modulo that is always in the range 0 to |b| − 1, computed as ((a % b) + |b|) % |b|. It is handy for wrapping indices and clock arithmetic.
Can the divisor be zero?
No. Dividing by zero is undefined, so the divisor must be non-zero.
Does it work with decimals?
This tool focuses on integer modulo, where the quotient and remainder are whole numbers.
Sources & references
External references open in a new tab. We are independent and not affiliated with these organizations.
- ✓ Free to use
- ✓ No sign-up required
- ✓ Runs entirely in your browser — nothing is uploaded.
- ✓ Formula and method shown above
Provided “as is” for general information only — results may be inaccurate, so verify before you rely on them. No warranty; use at your own risk.
Built and reviewed by HIFreeTools against the formula shown above and any authoritative references cited on this page. See our methodology and editorial standards.
Related tools
- LCM & GCD CalculatorCalculators
- Prime Number CheckerCalculators
- Rounding CalculatorCalculators
- Exponent CalculatorCalculators
- Scientific CalculatorScience & Engineering
- Ratio CalculatorCalculators
Embed this tool on your site
Free to embed, no sign-up. Paste this code where you want the modulo calculator to appear: