# 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 ${\displaystyle a}$ and a non-zero natural number ${\displaystyle d}$, it can be shown that there exist unique integers ${\displaystyle q}$ and ${\displaystyle r}$, such that ${\displaystyle a=qd+r}$ and ${\displaystyle 0\leq r. The number ${\displaystyle q}$ is called the quotient, while ${\displaystyle r}$ is called the remainder.[1][2]

## The case of general integers

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

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

${\displaystyle -42=9\times -5+3}$

or

${\displaystyle -42=8\times -5+-2}$.

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 ${\displaystyle d}$. This holds in general. When dividing by ${\displaystyle d}$, if the positive remainder is ${\displaystyle r_{1}}$, and the negative one is ${\displaystyle r_{2}}$, then

${\displaystyle r_{1}=r_{2}+d}$.

## The remainder for real numbers

When ${\displaystyle a}$ and ${\displaystyle d}$ are real numbers, with ${\displaystyle d}$ being non-zero, then ${\displaystyle a}$ can be divided by ${\displaystyle d}$ 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 ${\displaystyle q}$ and a unique real remainder ${\displaystyle r}$ such that ${\displaystyle a=qd+r}$ with ${\displaystyle 0\leq r<|d|}$. Similar to the case of division of integers, the remainder could be required to be negative, that is, ${\displaystyle -|d|.

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.

## References

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