# Remainder

In arithmetic, the result of the division of two integers usually cannot be expressed with an integer quotient, unless a **remainder—**an amount "left over" after the division—is also accepted.

## The remainder for natural numbers

Given a natural number [math]\displaystyle{ a }[/math] and a non-zero natural number [math]\displaystyle{ d }[/math], it can be shown that there exist unique integers [math]\displaystyle{ q }[/math] and [math]\displaystyle{ r }[/math], such that [math]\displaystyle{ a=qd+r }[/math] and [math]\displaystyle{ 0\leq r\lt d }[/math]. The number [math]\displaystyle{ q }[/math] is called the *quotient*, while [math]\displaystyle{ r }[/math] is called the *remainder*.^{[1]}^{[2]}

## The case of general integers

If [math]\displaystyle{ a }[/math] and [math]\displaystyle{ d }[/math] are integers with [math]\displaystyle{ d }[/math] being non-zero, then a remainder is an integer [math]\displaystyle{ r }[/math] such that [math]\displaystyle{ a=qd+r }[/math] for some integer [math]\displaystyle{ q }[/math], and with [math]\displaystyle{ 0\leq|r|\lt |d| }[/math].

When defined this way, there are two possible remainders. For example, the division of -42 by -5 can be expressed as either

- [math]\displaystyle{ -42=9\times-5+3 }[/math]

or

- [math]\displaystyle{ -42=8\times-5+-2 }[/math].

So the remainder is then either 3 or -2.

This ambiguity in the value of the remainder is not very serious; in the case above, the negative remainder is obtained from the positive one just by subtracting 5, which is [math]\displaystyle{ d }[/math]. This holds in general. When dividing by [math]\displaystyle{ d }[/math], if the positive remainder is [math]\displaystyle{ r_1 }[/math], and the negative one is [math]\displaystyle{ r_2 }[/math], then

- [math]\displaystyle{ r_1=r_2+d }[/math].

## The remainder for real numbers

When [math]\displaystyle{ a }[/math] and [math]\displaystyle{ d }[/math] are real numbers, with [math]\displaystyle{ d }[/math] being non-zero, then [math]\displaystyle{ a }[/math] can be divided by [math]\displaystyle{ d }[/math] without remainder, with the quotient being another real number. If the quotient is constrained to being an integer, however, the concept of remainder is still necessary. It can be proven that there exists a unique integer quotient [math]\displaystyle{ q }[/math] and a unique real remainder [math]\displaystyle{ r }[/math] such that [math]\displaystyle{ a=qd+r }[/math] with [math]\displaystyle{ 0\leq r\lt |d| }[/math]. Similar to the case of division of integers, the remainder could be required to be negative, that is, [math]\displaystyle{ -|d|\lt r\leq0 }[/math].

Extending the definition of remainder for real numbers, as described above, is not of theoretical importance in mathematics; however, many programming languages implement this definition—see modulation for more.

## Related pages

- Divisor, a number which evenly divides another
- Long division
- Modular arithmetic
- Modulation

## References

- ↑ "The Definitive Higher Math Guide to Long Division and Its Variants — for Integers".
*Math Vault*. 2019-02-24. Retrieved 2020-08-27. - ↑ "The quotient remainder theorem (article) | Khan Academy".
*Khan Academy*. Retrieved 2020-08-27.