1.5: The Division Algorithm
( \newcommand{\kernel}{\mathrm{null}\,}\)
The goal of this chapter is to introduce and prove the following important result.
If a and b are integers and b>0 then there exist unique integers q and r satisfying the two conditions: a=bq+rand0≤r<b.
In this situation q is called the quotient and r is called the remainder when a is divided by b. We sometimes refer to a as the dividend and b as the divisor.
(Some care must be taken with this last term, in light of how the divisor of an integer was defined in Section 1.4. It is correct both to say that 2 is not a divisor of 7, since 2∤7, though 2 is the divisor when 7 is divided by 2, yielding 7=2⋅3+1. Context should make it clear which meaning is intended.)
Note that there are two parts to the Division Algorithm’s statement. One part is the existence of integers q and r satisfying (???), and the second part is the uniqueness of the integers q and r satisfying (???).
Proof
We first prove the existence of q and r.
If b divides a then a=kb for some integer k, and we may write q=k and r=0.
Suppose instead that b does not divide a, and consider the collection …,a−3b,a−2b,a−b,a,a+b,a+2b,a+3b,… of integers. Let S be the set of all these numbers that are non-negative. In symbols, S={a−kb∣k∈Z and a−kb≥0}.
The set S is non-empty, since by the Archimedean Property there exists a natural number n such that n>−a and so nb≥n>−a and hence a−(−n)b>0. Now by the Well-Ordering Principle S contains a smallest element; call it r. By our definition of S, this means that for some particular integer q we have r=a−qb. Thus a=bq+r, and it only remains to show that 0≤r<b.
All the elements of S are positive, so it is clear that 0≤r. If it is not true that r<b, then a−bq≥b and so r−b=a−(q+1)b≥0; thus either r−b is an element of S or r−b=0. Since r was defined as the smallest element of S, it cannot be true that r−b is in S. However, if r−b=0, then a=bq+b=(q+1)b, which contradicts our assumption that b does not divide a. We are forced to conclude that 0≤r<b.
We still have to prove that q and r are uniquely determined. To do this we suppose that a=bq1+r1and0≤r1<b, and a=bq2+r2and0≤r2<b for integers q1,q2,r1,r2. We must show that r1=r2 and q1=q2. If r1≠r2 without loss of generality we can assume that r2>r1. Subtracting these two equations we obtain 0=a−a=(bq1+r1)−(bq2+r2)=b(q1−q2)+(r1−r2). This implies that r2−r1=b(q1−q2). This implies that b∣r2−r1. By Theorem 1.4.1(10) this implies that b≤r2−r1. But since 0≤r1<r2<b we have r2−r1<b. This contradicts b≤r2−r1. So we must conclude that r1=r2. Now from (???) we have 0=b(q1−q2). Since b>0 this tells us that q1−q2=0, that is, q1=q2. This completes the proof of the uniqueness of r and q in (???).
In number theory we usually prefer to work with integers, but if we are willing to consider division of real numbers, it can be shown that when a is divided by b, the quotient and remainder satisfy q=⌊ab⌋andr=a−bq=a−b⌊ab⌋ (see Exercise 1.5.2).
We now turn to some familiar concepts.
An integer n is even if n=2k for some k, and is odd if n=2k+1 for some k.
By the parity of an integer we mean whether it is even or odd.
Sometimes a problem in number theory can be solved by dividing the integers into various classes depending on their remainders when divided by some number b. For example, this is helpful in solving Exercises 1.5.5 and 1.5.6 at the end of this chapter.
For b>0 define amodb as the value of r in the pair q,r satisfying the expressions a=bq+r and 0≤r<b.
In other words, amodb is the remainder given by the Division Algorithm when a is divided by b.
For example 23mod7=2 since 23=7⋅3+2 and −4mod5=1 since −4=5⋅(−1)+1.
Note that some calculators and most programming languages have a function often denoted by MOD(a,b) or mod(a,b) whose value is what we have just defined as amodb. When this is the case the values r and q in the Division Algorithm for given a and b>0 are given by r=amodbq=a−(amodb)b If also the floor function is available we have r=amodbq=⌊a/b⌋
Exercises
Find the values of q and r in the Division Algorithm for the following values of a and b:
- Let b=3 and a=0,1,−1,10,−10.
- Let b=345 and a=0,−1,1,344,7863,−7863.
Given integers b>0 and a, let q and r be the quotient and remainder when b is divided by a, so a=bq+r. Carefully prove that q=⌊ab⌋.
Using the Division Algorithm, prove that every integer is either even or odd, but never both.
Prove n and n2 always have the same parity. That is, n is even if and only if n2 is even.
Show that for all integers n the number n3−n always has 3 as a factor.
(Hint: by the Division Algorithm, every integer n falls into one of three cases: n=3k, n=3k+1, n=3k+2. Prove that n3−n is divisible by 3 for each of these cases separately.)
Show that the product of any three consecutive integers has 6 as a factor. (How many cases should you use here?)
Prove the following:
- If b>0 and b∣a, then amodb=0.
- If b>0 and amodb=0, then b∣a.
Calculate the following:
- 0mod10
- 123mod10
- 10mod123
- 457mod33
- (−7)mod3
- (−3)mod7
- (−5)mod5
- Use the Division Algorithm to prove the following similar theorem: If b>0 then for any a there exists unique integers p and s such that a=bp+sand⌊−b/2⌋<s≤⌊b/2⌋.
- Find integers p and s such that a=bp+s and ⌊−b/2⌋<s≤⌊b/2⌋ for
- a=36,b=13
- a=75,b=50
- a=75,b=49.