# What is the remainder when I divide?

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.

- Page: https://www.acalculator.org/math/remainder-calculator
- JSON spec: https://www.acalculator.org/math/remainder-calculator.json
- Version: 522bc95c9fbe

## Default answer

Example with the default inputs (Dividend 17, Divisor 5): 17 ÷ 5 = 3 remainder 2.

## Inputs

| Key | Label | Description |
| --- | --- | --- |
| a | Dividend | The whole number being divided (a). It may be negative. |
| b | Divisor | The whole number to divide by (b), 1 or more. |

## Outputs

| Key | Label | Description |
| --- | --- | --- |
| remainder | Remainder | What is left after taking away as many whole divisors as fit: r, from 0 up to b − 1. |
| quotient | Quotient | How many whole times the divisor fits: q, rounded down (toward minus infinity). |
| check | Check | The division written back as a multiplication: a = b × q + r. |
| decimal | Exact quotient | The dividend divided by the divisor as an exact decimal, a ÷ b = q + r ÷ b, to 12 decimal places; … means more digits follow. |

## 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.

## Assumptions

- 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

1. a = 17, b = 5 gives quotient = 3, remainder = 2, decimal = 3.4, check = 17 = 5 × 3 + 2. Source: hand calculation in content.mdx: 5 × 3 = 15, 17 − 15 = 2.
2. a = 100, b = 7 gives quotient = 14, remainder = 2, decimal = 14.285714285714…. Source: hand calculation in content.mdx: 7 × 14 = 98, 100 − 98 = 2.
3. a = -17, b = 5 gives quotient = -4, remainder = 3, decimal = -3.4, check = −17 = 5 × (−4) + 3. Source: Sundstrom, Mathematical Reasoning: Writing and Proof, section 3.5 (the division algorithm): −17 = 5(−4) + 3.
4. a = 12, b = 4 gives quotient = 3, remainder = 0. Source: hand calculation in content.mdx: 4 × 3 = 12 exactly, so the remainder is 0.
5. a = 3, b = 8 gives quotient = 0, remainder = 3, decimal = 0.375. Source: hand calculation in content.mdx: 8 does not fit into 3, so q = 0 and r = 3.
6. a = 18446744073709551616, b = 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).

## FAQ

### 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.

## Sources

- Ted Sundstrom, Mathematical Reasoning: Writing and Proof, §3.5 The Division Algorithm and Congruence (for integers a and b with b > 0 there are unique q and r with a = bq + r and 0 ≤ r < b; −17 = 5(−4) + 3). https://math.libretexts.org/Bookshelves/Mathematical_Logic_and_Proof/Book:_Mathematical_Reasoning__Writing_and_Proof_(Sundstrom)/03:_Constructing_and_Writing_Proofs_in_Mathematics/3.05:_The_Division_Algorithm_and_Congruence
- Donald E. Knuth, The Art of Computer Programming, Vol. 1, §1.2.4 (x mod y = x − y⌊x ÷ y⌋).
