Remainder Calculator
Enter a dividend and divisor to get the quotient, remainder, verification equation (a = b × q + r), greatest common divisor and fraction / mixed-number forms; big integers supported.
Splitting things up, rotating shifts, taking a modulo in code — they are all the same question: divide by a number, what is left? A student wants the check equation; a programmer wants a remainder that behaves the same across languages. Yet the two answers diverge the moment negatives appear. This tool gives the quotient, remainder, check equation and fraction form together, with both conventions side by side.
The difference between the conventions is the point: the mathematical convention keeps the remainder non-negative (−7 ÷ 3 = −3 remainder 2), most programming languages follow the sign of the dividend (C/Java/JS: −7 % 3 = −1), and Python's % follows the divisor (−7 % 3 = 2). Port code between languages and your modulo can be off by a whole divisor — both results are shown and labelled here.
Did this tool solve your problem?
Submitting sends the tool name, your input and the current result to the server. Please do not include ID numbers, phone numbers or other private data.
AI assistant It answers using your current input and result
Asking again sends your current input and result to the server once more. Please do not include private data.
How to use
- Enter the dividend and the divisor (negatives and large integers are supported).
- Read the quotient, remainder and check equation; compare the fraction and mixed-number forms.
- Compare the mathematical and programming remainders — they differ for negatives.
- Copy the result; when coding, follow the % semantics of your target language.
How it works
How division with remainder works
Division with remainder simply states "not exactly divisible" precisely: a = b × q + r. Take the largest integer multiple that does not exceed the dividend to get the quotient q; what is left over is the remainder r. For 100 ÷ 7: 7 × 14 = 98 is the closest multiple at or below 100, so the quotient is 14, the remainder 2, and the check equation reads 100 = 7 × 14 + 2. When the remainder is 0 the division is exact.
Two remainder conventions for negatives
Negatives are where the two conventions part ways. The mathematical (Euclidean) convention requires 0 ≤ r < |b|, so the remainder is never negative: −7 ÷ 3 is written 3 × (−3) + 2 = −7, giving quotient −3 and remainder 2. The programming convention (the % operator in C, Java and JavaScript) follows the sign of the dividend: −7 % 3 = −1, with quotient −2. Both are valid; this tool defaults to the mathematical convention and switches with one click.
What remainders are used for
Remainders have three common uses: testing divisibility (r = 0, e.g. whether a number divides by 3), cyclic wrapping (hash table indices, circular queues, rotating shifts by weekday), and turning improper fractions into mixed numbers (7/3 = 2 + 1/3 is exactly quotient and remainder). The Euclidean algorithm for the greatest common divisor is itself repeated division with remainder, so this tool also reports gcd(|a|, |b|).
Calculation basis: a = b × q + r. The mathematical (Euclidean) convention takes 0 ≤ r < |b| with the quotient floored towards −∞, while the programming convention keeps the sign of the dividend with the quotient truncated towards zero. Integer arithmetic uses BigInt (up to 1000 digits) and the GCD uses the Euclidean algorithm.
Code example
JavaScript Two remainder conventions
const divmod = (a, b) => {
const q = Math.trunc(a / b); // quotient truncated toward zero (C/Java/JS)
const rProg = a % b; // programming convention: sign follows the dividend
const rMath = ((a % b) + b) % b; // mathematical convention: never negative
return { q, rProg, rMath };
};
divmod(-7, 3); // { q: -2, rProg: -1, rMath: 2 }
Python divmod returns both at once
divmod(-7, 3) # (-3, 2) (Python: the quotient floors, the remainder follows the divisor)
divmod(17, 5) # (3, 2)
# Note that Python and C/Java differ on %:
# -7 % 3 is 2 in Python and -1 in JS/Java
# Check this whenever you port modulo logic between languages
FAQ
What is the formula for division with remainder?
a = b × q + r, where a is the dividend, b the divisor, q the quotient and r the remainder, with 0 ≤ r < |b|. For 100 ÷ 7: 100 = 7 × 14 + 2, so the quotient is 14 and the remainder 2 — 13 does not work because 7 × 13 = 91 leaves 9, and 15 overshoots with 7 × 15 = 105.
How do you compute the remainder when the dividend is negative?
It depends on the convention. The mathematical convention requires a non-negative remainder: −7 ÷ 3 = 3 × (−3) + 2, quotient −3, remainder 2. The programming convention truncates toward zero: −7 % 3 = −1, quotient −2. Maths problems and number theory almost always use the first; in code, mind that most languages default to the second.
Why does the same division have two different remainders?
Because the quotient is rounded in different directions. Rounding toward negative infinity (floor) yields a non-negative remainder; rounding toward zero (truncate) makes the remainder follow the sign of the dividend. Both satisfy a = b × q + r — they simply pick a different q, so r differs too. Here the remainders are 2 and −1, which differ by exactly one divisor.
Can decimals be used with division with remainder?
This tool handles integers only, because division with remainder is defined for integers. If the dividend or divisor has decimals, multiply both by a power of ten first: 7.5 ÷ 2 becomes 75 ÷ 20, giving quotient 3 and remainder 15 (divide by 10 to get 1.5). For division involving fractions, use the fraction calculator instead.
How large a number can it handle?
Arithmetic uses BigInt, so numbers up to 1,000 digits are fine. For example 12345678901234567890 ÷ 97 = 127275040218913071 remainder 3 — the check equation matches exactly, with no floating-point drift. Beyond 1,000 digits it asks you to reduce the size, a safeguard against freezing the page.
What does a remainder of 0 mean?
That the division is exact — the dividend is an integer multiple of the divisor, and the quotient is the exact ratio (12 ÷ 4 = 3). This tool flags it as an exact division (remainder 0). To test divisibility by 3 or 9 quickly, you can also use the digit sum.
Are mixed numbers and division with remainder the same thing?
Essentially yes. 7 ÷ 3 has quotient 2 and remainder 1, which as a mixed number is 2 + 1/3 — shown directly in the mixed-number row. Working backwards from 2 + 1/3, the numerator is 2 × 3 + 1 = 7. If numerator and denominator share a factor, the fraction row is reduced first.
Why is the greatest common divisor included?
Because the Euclidean algorithm for the GCD is repeated division with remainder: gcd(a, b) = gcd(b, a mod b) until the remainder is 0, and the last non-zero remainder is the GCD. This tool computes gcd(|a|, |b|) along the way, which is handy for reducing and comparing fractions.