What is the remainder when I divide?
Type a whole number and a divisor to get the whole-number quotient and the remainder, with the check a = b × q + r.
- Remainder
- 2
17 ÷ 5 = 3 remainder 2.
- Quotient
- 3
- Check
- 17 = 5 × 3 + 2
- Exact quotient
- 3.4
Remainder: 2. 17 ÷ 5 = 3 remainder 2.
How to calculate
Divides one whole number by another and gives the whole-number quotient and the remainder, a = b × q + r with 0 ≤ r < b, exactly at any size.
Example with the default inputs (Dividend 17, Divisor 5): 17 ÷ 5 = 3 remainder 2.
Method: The division algorithm: for a whole number a and a whole number b ≥ 1 there is exactly one pair q, r with a = b × q + r and 0 ≤ r < b. q = ⌊a ÷ b⌋ and r = a − b × q.
- Both numbers are whole numbers. The divisor is 1 or more; the dividend may be negative or zero.
- The remainder is never negative, even for a negative dividend: −17 ÷ 5 is −4 remainder 3, because 5 × (−4) + 3 = −17.
- The quotient, the remainder and the exact quotient are exact at any size; the exact quotient shows 12 decimal places, then … when more digits follow.
Worked examples
Each example is checked against the calculator on every build.
- Dividend 17, Divisor 5 gives Quotient 3, Remainder 2, Exact quotient 3.4, Check 17 = 5 × 3 + 2.Source: hand calculation in content.mdx: 5 × 3 = 15, 17 − 15 = 2
- Dividend 100, Divisor 7 gives Quotient 14, Remainder 2, Exact quotient 14.285714285714….Source: hand calculation in content.mdx: 7 × 14 = 98, 100 − 98 = 2
- Dividend -17, Divisor 5 gives Quotient -4, Remainder 3, Exact quotient -3.4, Check −17 = 5 × (−4) + 3.Source: Sundstrom, Mathematical Reasoning: Writing and Proof, section 3.5 (the division algorithm): −17 = 5(−4) + 3
- Dividend 12, Divisor 4 gives Quotient 3, Remainder 0.Source: hand calculation in content.mdx: 4 × 3 = 12 exactly, so the remainder is 0
- Dividend 3, Divisor 8 gives Quotient 0, Remainder 3, Exact quotient 0.375.Source: hand calculation in content.mdx: 8 does not fit into 3, so q = 0 and r = 3
- Dividend 18446744073709551616, Divisor 7 gives Quotient 2635249153387078802, Remainder 2.Source: hand calculation in content.mdx: 2⁶⁴ = 7 × 2,635,249,153,387,078,802 + 2; Python 3: divmod(2**64, 7)
How it works
For a whole number a (the dividend) and a whole number b of 1 or more (the divisor), the division algorithm says there is exactly one pair of whole numbers q (the quotient) and r (the remainder) with
a = b × q + r and 0 ≤ r ≤ b − 1 (the remainder is less than the divisor)
The calculator finds them as:
- q = ⌊a ÷ b⌋, the quotient rounded down (toward minus infinity)
- r = a − b × q
It also shows the check a = b × q + r and the exact quotient a ÷ b = q + r ÷ b as a decimal, worked out by long division with whole numbers, so every digit is right at any size.
Assumptions
- Both numbers are whole numbers. The divisor is 1 or more. The dividend can be 0 or negative.
- The remainder is never negative. For a negative dividend the quotient is rounded down, so −17 ÷ 5 gives q = −4 and r = 3.
- The quotient and remainder are exact whole numbers at any size.
- The exact quotient is text: the whole part of |a| ÷ b with thousands separators, then up to 12 decimal places of |a| ÷ b cut off (not rounded), with a hyphen in front when a is negative. The division stops when nothing is left over, so 17 ÷ 5 is 3.4 and 12 ÷ 4 is 3. When something is still left over after the 12th place, all 12 places are kept and "…" follows: 100 ÷ 7 is 14.285714285714…, and 1 ÷ 6 is 0.166666666666… (cut off, not rounded to …667).
- The check is written a = b × q + r with thousands commas and the minus sign −, and a negative quotient in brackets: −17 = 5 × (−4) + 3.
Worked examples by hand
17 ÷ 5. 5 × 3 = 15 fits, 5 × 4 = 20 does not, so q = 3 and r = 17 − 15 = 2. The exact quotient is 3 + 2 ÷ 5 = 3.4.
100 ÷ 7. 7 × 14 = 98, so q = 14 and r = 100 − 98 = 2. The exact quotient is 14 + 2 ÷ 7 = 14.285714285714….
−17 ÷ 5. −17 ÷ 5 = −3.4, rounded down to q = −4. Then r = −17 − 5 × (−4) = −17 + 20 = 3.
12 ÷ 4. 4 × 3 = 12 exactly, so q = 3 and r = 0.
3 ÷ 8. 8 does not fit into 3, so q = 0 and r = 3. The exact quotient is 3 ÷ 8 = 0.375.
2⁶⁴ ÷ 7. 2⁶⁴ = 18,446,744,073,709,551,616. 7 × 2,635,249,153,387,078,802 = 18,446,744,073,709,551,614, which is 2 less, so q = 2,635,249,153,387,078,802 and r = 2. (Check: 2⁶⁴ mod 7 = 2, because 2³ = 8 leaves 1, and 2⁶⁴ = (2³)²¹ × 2.)
Other questions people ask
How do I find the remainder?
Find how many whole times the divisor fits into the dividend, multiply back, and subtract. For 17 ÷ 5: 5 fits 3 times (5 × 3 = 15), and 17 − 15 = 2, so the remainder is 2. Written out: 17 ÷ 5 = 3 R 2.
How do I turn a remainder into a fraction or a decimal?
Put the remainder over the divisor. 17 ÷ 5 = 3 R 2 = 3 2/5 = 3.4. The calculator shows the decimal as the exact quotient.
What is the remainder when a negative number is divided?
This calculator follows the division algorithm, where the remainder is never negative: −17 ÷ 5 = −4 R 3, because 5 × (−4) + 3 = −17. Some programming languages give −3 R −2 instead; both satisfy a = b × q + r, but only the first keeps 0 ≤ r < b.
What does a remainder of 0 mean?
The divisor goes into the dividend exactly, so the divisor is a factor of the dividend. 12 ÷ 4 = 3 R 0, so 4 divides 12.
What if the divisor is bigger than the dividend?
The divisor fits 0 times, so the quotient is 0 and the whole dividend is the remainder: 3 ÷ 8 = 0 R 3.
Is the remainder the same as the modulo?
For a positive divisor, yes: a mod b is the remainder r with 0 ≤ r < b. 17 mod 5 = 2. The modulo calculator also handles negative and decimal divisors.
How large can the numbers be?
The quotient and remainder are exact for whole numbers of any size a phone can store, well past the 16 digits an ordinary calculator keeps. 2⁶⁴ ÷ 7 is 2,635,249,153,387,078,802 remainder 2.