Chapter 1 Greatest common divisor 1.1 The division theorem In the beginning, there are the natural numbers 0, 1, 2, 3, 4,..., which constitute the set N. Addition and multiplication are binary operations on N in the sense that the sum and the product of two natural numbers are also natural numbers. The difference of two natural numbers, however, is not necessarily a natural number. If a<bin N, then a b is a negative integer. 1 Neither is division a binary operation in N. In most cases, division of one natural number by another entails a remainder. 1 For the construction of integers from natural numbers, see??.
102 Greatest common divisor Theorem 1.1 (Division theorem). Given nonnegative integers a and b>0, there are unique natural numbers q and r satisfying (i) a = qb + r, (ii) 0 r<b. Proof. (1) Existence part. The sequence of integers, beginning with a, and repeatedly subtracting b, is strictly decreasing: a>a b>a 2b > >a qb >. The numbers will eventually become negative, 2 and there is a natural number q for which a qb 0 and a (q +1)b<0. If we write r = a qb, then since 0 >a (q +1)b =(a qb) b = r b, it follows that r<b. The conditions (i) and (ii) are satisfied. (2) Uniqueness part. Suppose a = q 1 b + r 1 = q 2 b + r 2, with both r 1 and r 2 smaller than b. Ifr 1 and r 2 are unequal, we may assume r 1 >r 2. Then q 1 b<q 2 b and we must have q 1 <q 2. In fact, r 1 r 2 =(q 2 q 1 )b b. This contradicts r 1 r 2 < r 1 < b. Therefore, we must have r 1 = r 2. Consequently, q 1 = q 2. In the division theorem above, q and r are called the quotient and the remainder of the division of a by b. If r =0, then we say that a is divisible by b, and write b a. 2 The fact that there is no strictly decreasing infinite sequence of natural numbers is called the well ordering principle. It is equivalent to the statement that every nonempty set of natural numbers must have a smallest element.
1.1 The division theorem 103 1.1.1 Writing a positive integer in a given base b Let a be a fixed positive integer. Given a positive integer a, by repeated applications of the division theorem, we have This means and we write a = qb + r 0, b = q 1 r 0 + r 1, r 0 = q 2 r 1 + r 2,. r n 2 = q n r n 1 + r n, r n 1 = q n+1 r n. a = r n b n + r n 1 b n 1 + + r 1 b + r 0, a =(r n r n 1 r 1 r 0 ) b and say that this is the base b representation of the integer a. The digits r 0, r 1,...,r n 1, r n are all between 0 and b 1.
104 Greatest common divisor 1.1.2 Calculation of an integer from its base b representation The integer a =(r n r n 1 r 2 r 1 r 0 ) b can be computed efficiently from the following table: r n r n 1 r 2 r 1 r 0 b q n 1 b q 2 b q 1 b qb q n 1 q n 2 q 1 q a
1.1 The division theorem 105 1.1.3 Multiplication of numbers in base a Basic addition and multiplication tables in base 5: + 1 2 3 4 1 2 3 4 10 2 3 4 10 11 3 4 10 11 12 4 10 11 12 13 (43) 5 (24) 5 : 1 2 3 4 1 1 2 3 4 2 2 4 11 13 3 3 11 14 22 4 4 13 22 31 4 3 2 4 3 3 2 1 4 1 2 2 4 2
106 Greatest common divisor 1.2 The euclidean algorithm For natural numbers a and b, the greatest common divisor of a and b is denoted by gcd(a, b). The division theorem allows a drastic simplification of the problem of finding gcd(a, b). Lemma 1.2. Suppose a = qb + r. Then (i) every common divisor of a and b is a common divisor of b and r; (ii) every common divisor of b and r is a common divisor of a and b; consequently, (iii) the common divisors of a and b are exactly the same as the common divisors of b and r, and (iv) gcd(a, b) =gcd(b, r). These observations lead to a straightforward calculation of gcd(a, b): replace the larger number by the remainder and keep on performing division until exact divisibility. To be systematic, we write a = r 1 and b = r 0. r 1 = r 0 q 0 + r 1, 0 r 1 <r 0, r 0 = r 1 q 1 + r 2, 0 r 2 <r 1, r 1 = r 2 q 2 + r 3, 0 r 3 <r 2, r 2 = r 3 q 3 + r 4, 0 r 4 <r 3,. This division process eventually terminates since the remainders are strictly decreasing: r 1 >r 0 >r 1 >r 2 >. In other words, some r n divides the preceding r n 1 (and leaves a remainder r n+1 =0). From these,. r n 2 = r n 1 q n 1 + r n, 0 r n <r n 1, r n 1 = r n q n. gcd(a, b) =gcd(r 1,r 0 )=gcd(r 0,r 1 )= =gcd(r n 2,r n 1 )=gcd(r n 1,r n )=r n.
1.2 The euclidean algorithm 107 Example 1.1. gcd(1876, 365) = 1. r k q k 1876 365 5 51 7 8 6 3 2 2 1 1 2 0
108 Greatest common divisor 1.3 The Bezout identity: gcd(a, b) = ax + by If, along with these divisions, we introduce two more sequences (x k ) and (y k ) with the same rule but specific initial values, namely, x k+1 =x k 1 q k x k, x 1 =1, x 0 =0; y k+1 =y k 1 q k y k, y 1 =0, y 0 =1. then we obtain gcd(a, b) as an integer combination of a and b: 3 gcd(a, b) =r n = ax n + by n. k r k q k x k y k 1 a 1 0 0 b a 0 1 1 a a b b b r 1 x 1 y 1. n 1 r n 1 q n 1 x n 1 y n 1 n r n q n x n y n n +1 0 It can be proved that x n <band y n <a. The relation gcd(a, b) =ax + by for some integers x and y is called the Bezout identity. It is very important, both practically and theoretically. 3 In each of these steps, r k = ax k + by k.
1.3 The Bezout identity: gcd(a, b) =ax + by 109 Exercise Find the gcd of the following pairs of numbers by completing the second column of each table. In each case, express the gcd as an integer combination of the given numbers by completing the last two columns. 1. 2. r k q k x k y k 1876 1 0 365 5 0 1 51 7 8 6 3 2 2 1 1 2 0 r k q k x k y k 11213 1 0 1001 0 1
110 Greatest common divisor 1.4 Solution of linear Diophantine equations Theorem 1.3. Let a, b, c be integers, a and b nonzero. Consider the linear Diophantine equation ax + by = c. (1.1) 1. The equation (1.1) is solvable in integers if and only if d := gcd(a, b) divides c. 2. If this condition is satisfied, a particular solution can be obtained from the Bezout identity. 3. If (x, y) =(x 0,y 0 ) is a particular solution of (1.1), then every integer solution is of the form where t is an integer. x = x 0 + b d t, y = y 0 a d t,
1.4 Solution of linear Diophantine equations 111 Examples 1. Consider the Diophantine equation 3x +4y =5. Since it has a particular solution (x, y) =(3, 1), its general integer solution is (x, y) = (3 4t, 1+3t) for an arbitrary integer t. 2. Somebody received a check, calling for a certain amount of money in dollars and cents. When he went to cash the check, the teller made a mistake and paid him the amount which was written as cents, in dollars, and vice versa. Later, after spending $ 3.50, he suddenly realized that he had twice the amount of the money the check called for. What was the amount on the check? 3. Find the largest possible integer c for which the Diophantine equation 5x +7y = c has exactly three solutions in positive integers. 4. (a) Find the largest positive integer which cannot be written in the form 7x+11y for integers x, y 0. Let S := {7x+11y : x, y nonnegative integers}. Arrange the positive integers in the form 1 8 15 22 29 36 43 50 57 64 71... 2 9 16 23 30 37 44 51 58 65 72... 3 10 17 24 31 38 45 52 59 66 73... 4 11 18 25 32 39 46 53 60 67 74... 5 12 19 26 33 40 47 54 61 68 75... 6 13 20 27 34 41 48 55 62 69 76... 7 14 21 28 35 42 49 56 63 70 77... Observations: (i) Every number in the bottom row, being a positive multiple of 7, is in S. (ii) Among the first 11 columns, along each of the first 6 rows, there is a unique entry (with asterisk) which is a multiple of 11. This entry with asterisk, and those on its right along the row, are in S. (iii) None of the entries on the left of an entry with asterisk is in S. (iv) The entries with asterisks are on different columns. (v) The rightmost entry with an asterisk is 66. From this, the largest integer not in S is 66 7=59. (b) Given relatively prime integers a and b, what is the largest integer which cannot be written as ax + by for nonnegative integers x and y?
112 Greatest common divisor 1.5 Some important consequences of the Bezout identity Theorem 1.4 (Bezout s identity). Given relatively prime integers a>b, there are integers x, y such that ax + by =1. It is possible to choose x and y with x < b and y < a. Corollary 1.5. Let a and b be relatively prime. For every integer c, there is an integer x such that ax c is divisible by b. Proof. Suppose ah + bk =1. Then a(hc) +b(kc) =c and a(hc) c = b(kc) is divisible by b. Corollary 1.6. Let p be a prime number. For every integer a not divisible by p, there exists a positive integer b<psuch that ab 1 is divisible by p.
1.6 Appendix: Construction of integers from natural numbers 113 1.6 Appendix: Construction of integers from natural numbers Let S := N N be the set of ordered pairs of natural numbers. On the set S we define a relation R: (a, b)r(c, d) if and only if a + d = b + c. It is straightforward to verify that R is an equivalence relation, meaning that it is (i) reflexive: (ii) symmetric: and (iii) transitive. Therefore, there is a partition of S into equivalence classes: [a, b] :={(c, d) S :(a, b)r(c, d)}. Each equivalence class (of pairs of natural numbers) is called an integer. The set of integers is denoted by Z. Note that (a, b)r(a b, 0) if a b and (a, b)r(0,b a) if a<b. Therefore, each equivalence class is either [n, 0] or [0,n] for a natural number n. There is a natural inclusion ι : N Z given by ι(n) =[n, 0]. Under ι, weregardn as a subset of Z. In other words, we simply write [n, 0] as n and call this a positive integer if n is nonzero. On the other hand, we write [0,n] as n and call this a negative integer if n is nonzero. The addition and multiplication of integers are induced by the addition of multiplication of natural numbers: (iv) [a 1,b 1 ]+[a 2,b 2 ]=[a 1 + a 2,b 1 + b 2 ], (v) [a 1,b 1 ][a 2,b 2 ]=[a 1 a 2 + b 1 b 2,a 1 b 2 + a 2 b 1 ]. It is necessary to check that these operations do not depend on the choice of representatives. In other words, if [a 1,b 1 ]=[a 1,b 1 ] and [a 2,b 2 ]=[a 2,b 2 ], then for (iv) we must check that [a 1 + a 2,b 1 + b 2 ]=[a 1 + a 2,b 1 + b 2]. This is quite easy: (a 1 + a 2 )+(b 1 + b 2)= (a 1 + b 1)+(a 2 + b 2) = (a 1 + b 1 )+(a 2 + b 2 ) = (a 1 + a 2)+(b 1 + b 2 ). For (v) we must check the more complicated identity [a 1 a 2 + b 1 b 2,a 1 b 2 + a 2 b 1 ]=[a 1a 2 + b 1b 2,a 1b 2 + a 2b 1]. (a 1 a 2 + b 1 b 2 )+(a 1b 2 + a 2b 1)= (a 1 + b 1)(a 2 + b 2) = (a 1 + b 1 )(a 2 + b 2 )