In mathematics, the remainder is the amount "left over" after performing some computation. In arithmetic, the remainder is the integer "left over" after dividing one integer by another to produce an integer quotient (integer division). In algebra, the remainder is the polynomial "left over" after dividing one polynomial by another. The modulo operation is the operation that produces such a remainder when given a dividend and divisor.
Formally it is also true that a remainder is what is left after subtracting one number from another, although this is more properly called the difference. This usage can be found in some elementary textbooks; colloquially it is replaced by the expression "the rest" as in "Give me two dollars back and keep the rest."^{[1]} However, the term "remainder" is still used in this sense when a function is approximated by a series expansion and the error expression ("the rest") is referred to as the remainder term.
Contents

Integer division 1

Examples 2

For floatingpoint numbers 3

In programming languages 4

Polynomial division 5

See also 6

Notes 7

References 8

Further reading 9
Integer division
If a and d are integers, with d nonzero, it can be proven that there exist unique integers q and r, such that a = qd + r and 0 ≤ r < d. The number q is called the quotient, while r is called the remainder.
See Euclidean division for a proof of this result and division algorithm for algorithms describing how to calculate the remainder.
The remainder, as defined above, is called the least positive remainder or simply the remainder.^{[2]} The integer a is either a multiple of d or lies in the interval between consecutive multiples of d, namely, q⋅d and (q + 1)d (for positive q).
At times it is convenient to carry out the division so that a is as close as possible to an integral multiple of d, that is, we can write

a = k⋅d + s, with s ≤ d/2 for some integer k.
In this case, s is called the least absolute remainder.^{[3]} As with the quotient and remainder, k and s are uniquely determined except in the case where d = 2n and s = ± n. For this exception we have,

a = k⋅d + n = (k + 1)d  n.
A unique remainder can be obtained in this case by some convention such as always taking the positive value of s.
Examples
In the division of 43 by 5 we have:

43 = 8 × 5 + 3,
so 3 is the least positive remainder. We also have,

43 = 9 × 5  2,
and −2 is the least absolute remainder.
These definitions are also valid if d is negative, for example, in the division of 43 by −5,

43 = (−8)×(−5) + 3,
and 3 is the least positive remainder, while,

43 = (−9)×(−5) + (−2)
and −2 is the least absolute remainder.
In the division of 42 by 5 we have:

42 = 8 × 5 + 2,
and since 2 < 5/2, 2 is both the least positive remainder and the least absolute remainder.
In these examples, the (negative) least absolute remainder is obtained from the least positive remainder by subtracting 5, which is d. This holds in general. When dividing by d, either both remainders are positive and therefore equal, or they have opposite signs. If the positive remainder is r_{1}, and the negative one is r_{2}, then

r_{1} = r_{2} + d.
For floatingpoint numbers
When a and d are floatingpoint numbers, with d nonzero, a can be divided by d without remainder, with the quotient being another floatingpoint number. If the quotient is constrained to being an integer, however, the concept of remainder is still necessary. It can be proved that there exists a unique integer quotient q and a unique floatingpoint remainder r such that a = qd + r with 0 ≤ r < d.
Extending the definition of remainder for floatingpoint numbers as described above is not of theoretical importance in mathematics; however, many programming languages implement this definition, see modulo operation.
In programming languages
While there are no difficulties inherent in the definitions, there are implementation issues that arise when negative numbers are involved in calculating remainders. Different programming languages have adopted different conventions: Pascal chooses the result of the mod operation positive, but does not allow d to be negative or zero (so, a = (a div d )*d + a mod d is not always valid).^{[4]} C99 chooses the remainder with the same sign as the dividend a. (Before C99, the C language allowed other choices.) Perl, Python (only modern versions), and Common Lisp choose the remainder with the same sign as the divisor d. Haskell and Scheme offer two functions, remainder and modulo – PL/I has mod and rem, while Fortran has mod and modulo; in each case, the former agrees in sign with the dividend, and the latter with the divisor.
Polynomial division
Euclidean division of polynomials is very similar to Euclidean division of integers and leads to polynomial remainders. Its existence is based on the following theorem: Given two univariate polynomials a(x) and b(x) (with b(x) not the zero polynomial) defined over a field (in particular, the reals or complex numbers), there exist two polynomials q(x) (the quotient) and r(x) (the remainder) which satisfy:^{[5]}

a(x)=b(x)q(x)+r(x)
where

\deg(r(x))<\deg(b(x)),
where "deg(...)" denotes the degree of the polynomial (the degree of the constant polynomial whose value is always 0 is defined to be negative, so that this degree condition will always be valid when this is the remainder.) Moreover q(x) and r(x) are uniquely determined by these relations.
This differs from the Euclidean division of integers in that, for the integers, the degree condition is replaced by the bounds on the remainder r (nonnegative and less than the divisor, which insures that r is unique.) The similarity of Euclidean division for integers and also for polynomials leads one to ask for the most general algebraic setting in which Euclidean division is valid. The rings for which such a theorem exists are called Euclidean domains, but in this generality uniqueness of the quotient and remainder are not guaranteed.^{[6]}
Polynomial division leads to a result known as the Remainder theorem: If a polynomial f(x) is divided by x  k, the remainder is the constant r = f(k).^{[7]}
See also
Notes

^ Smith 1958, p. 97

^ Ore 1988, p. 30. But if the remainder is 0, it is not positive, even though it is called a "positive remainder".

^ Ore 1988, p. 32

^ Pascal ISO 7185:1990 6.7.2.2

^ Larson & Hostetler 2007, p. 154

^ Rotman 2006, p. 267

^ Larson & Hostetler 2007, p. 157
References

Larson, Ron; Hostetler, Robert (2007), Precalculus:A Concise Course, Houghton Mifflin,

Ore, Oystein (1988) [1948], Number Theory and Its History, Dover,

Rotman, Joseph J. (2006), A First Course in Abstract Algebra with Applications (3rd ed.), PrenticeHall,

Smith, David Eugene (1958) [1925], History of Mathematics, Volume 2, New York: Dover,
Further reading

Davenport, Harold (1999). The higher arithmetic: an introduction to the theory of numbers. Cambridge, UK: Cambridge University Press. p. 25.

Katz, Victor, ed. (2007). The mathematics of Egypt, Mesopotamia, China, India, and Islam : a sourcebook. Princeton: Princeton University Press.

Schwartzman, Steven (1994). "remainder (noun)". The words of mathematics : an etymological dictionary of mathematical terms used in english. Washington: Mathematical Association of America.

Zuckerman, Martin M. Arithmetic: A Straightforward Approach. Lanham, Md: Rowman & Littlefield Publishers, Inc.
This article was sourced from Creative Commons AttributionShareAlike License; additional terms may apply. World Heritage Encyclopedia content is assembled from numerous content providers, Open Access Publishing, and in compliance with The Fair Access to Science and Technology Research Act (FASTR), Wikimedia Foundation, Inc., Public Library of Science, The Encyclopedia of Life, Open Book Publishers (OBP), PubMed, U.S. National Library of Medicine, National Center for Biotechnology Information, U.S. National Library of Medicine, National Institutes of Health (NIH), U.S. Department of Health & Human Services, and USA.gov, which sources content from all federal, state, local, tribal, and territorial government publication portals (.gov, .mil, .edu). Funding for USA.gov and content contributors is made possible from the U.S. Congress, EGovernment Act of 2002.
Crowd sourced content that is contributed to World Heritage Encyclopedia is peer reviewed and edited by our editorial staff to ensure quality scholarly research articles.
By using this site, you agree to the Terms of Use and Privacy Policy. World Heritage Encyclopedia™ is a registered trademark of the World Public Library Association, a nonprofit organization.