Modulo Calculator
Find a mod b — the remainder when a is divided by b — along with the integer quotient and the non-negative (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.
FreeNo sign-upPrivate — runs in your browser, nothing is uploaded
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 a non-negative Euclidean result for negative dividends.
Formula & method
The tool computes the truncated quotient trunc(a ÷ b), which rounds toward zero (so −17 ÷ 5 gives −3, not −4), 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
Example 1: Basic remainder
- Input
- 17 mod 5
- Result
- 2
- Why
- 17 = 5 × 3 + 2, so the quotient is 3 and the remainder is 2.
Example 2: Larger numbers
- Input
- 100 mod 7
- Result
- 2
- Why
- 100 = 7 × 14 + 2, so the remainder is 2.
Example 3: Negative dividend
- Input
- −17 mod 5
- Result
- −2 (Euclidean 3)
- Why
- JS-style remainder takes the sign of a: −17 = 5 × (−3) + (−2). The non-negative 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 a non-negative 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?
No. This tool accepts whole numbers (integers) only, so the quotient and remainder are whole numbers too.
Sources & references
External references open in a new tab. We are independent and not affiliated with these organizations.
- Free
- No sign-up
- 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 below.
Related tools
Embed this tool on your site
Free to embed, no sign-up. Paste this code where you want the tool to appear: