Basic Notation and Properties of Integers Denote the set of natural numbers N = {1, 2, 3, . . .} and the set of integers Z = {. . . , −3, −2, −1, 0, 1, 2, 3, . . .}. Let a and b be integers. We say that a divides b (de noted a b) if b is a multiple of a, i.e. b = ka for some integer k. (A synonymous expression is that b is divisible by a; or that a is a divisor of b.) If a does not divide b we write a 6 b. For example we have 6 24; 8 −16; −5 35; 3 6 59; zero is divisible by every integer; every integer is divisible by one; and every integer is divisible by itself. A prime number is an integer p ≥ 2 whose only positive divisors are 1 and p. A composite number is a number n > 1 which is not prime. Thus every positive integer is either 1, or prime, or composite; and these three possibilities are mutually exclusive. Theorem 1 (Division Algorithm). Let a, d be integers with d ≥ 1. Then there exist unique integer values of q and r satisfying a = dq + r, 0 ≤ r < d. Proof. Let S = {a − dx : x ∈ Z}, and let P be the set of all non-negative elements of S. We first observe that P is non-empty. (The condition a − dx ≥ 0 is equivalent to x ≤ a/d; and there exist integers x satisfying this condition.) Since the set of all non-negative integers is well-ordered, we may select r to be the least element of P . By definition, r = a − qd ≥ 0 where q ∈ Z. We must have r < d; otherwise r ≥ d and the integer r − d < r satisfies 0 ≤ r − d = (a − qd) − d = a − (q + 1)d ∈ P which is impossible since r is the least element of P . We have proved the existence of q, r ∈ Z satisfying a = dq + r, 0 ≤ r < d. To prove uniqueness, suppose that a = dq 0 + r0 , 0 ≤ r0 < d; we must prove that q 0 = q and r0 = r. But d divides r0 − r = (q − q 0 )d. On the other hand, r, r0 ∈ {0, 1, 2, . . . , d − 1} forces r0 − r ∈ {−(d − 1), −(d − 2), . . . , −1, 0, 1, 2, . . . , d − 2, d − 1}. The only multiple of d in the latter set is 0, so we must have r0 − r = 0. This in turn means that (q − q 0 )d = r0 − r = 0; and since d > 0, we must have q 0 = q. 1 In the latter relation, we call d the divisor; q the quotient; and r the remainder upon dividing a by d. Note that d divides a if and only if the remainder r = 0. For example • dividing 50 by 12, we have 50 = 4·12 + 2 with quotient equal to 4 and remainder equal to 2; • dividing −50 by 12, we have −50 = −5·12 + 10 with quotient equal to −5 and remainder equal to 10; • dividing 48 by 6, we have 48 = 8·6 + 0 with quotient equal to 8 and remainder equal to 0 (thus 6 48); • dividing 35 by 47 we have 35 = 0·47 + 35 with quotient equal to 0 and remainder equal to 35. It would be more accurate to refer to the procedure of long-hand division (the usual method of obtaining q and r) as the actual division algorithm; but traditionally, Theorem 1 above also bears the name of the Division Algorithm (a slight misnomer). But the algorithm for computing q and r is well-known; and by tradition, Theorem 1 bears the same name as the algorithm. Theorem 2. Let a, b, d be integers, and assume d 6= 0. If d divides both a and b, then d divides both a+b and a−b. Moreover d divides every multiple of a. Proof. Suppose a = dr and b = ds for some r, s ∈ Z. Then both a+b = d(r + s) and a − b = d(r − s) are divisible by d. An integer is even if it is divisible by 2, or odd if it is one greater than an even integer. Thus even integers are those of the form 2k for some integer k; and odd integers are those of the form 2k+1 for some integer k. Theorem 3. Every integer is either even or odd, and never both. Proof. Let n be any integer. By the Division Algorithm, there exist unique integers q and r such that n = 2q + r where r ∈ {0, 1}. By definition n is even or odd according as r = 0 or r = 1. Theorem 4. Let m and n be integers. If m and n are both even, or both odd, then m + n is even. If one of m and n is even and the other is odd, then m + n is odd. Proof. If m = 2u and n = 2v for some integers u, v then m + n = 2(u + v) is even. If m = 2u + 1 and n = 2v + 1 then once again m + n = 2(u + v + 1) is even. The case where m is even and n is odd is done in practice exercise 3, and the case where m is odd and n is even is similar. 2 The divisors of 12 are ±1, ±2, ±3, ±4, ±6, ±12; also the divisors of 18 are ±1, ±2, ±3, ±6, ±9, ±18. The common divisors of 12 and 18 are thus ±1, ±2, ±3, ±6. So the greatest common divisor of 12 and 18 is 6. In general the greatest common divisor of two integers a and b is the largest integer which divides both a and b, and is denoted by gcd(a, b). Note that a and b cannot both be zero, or else every integer divides both a and b, in which case there is no greatest common divisor. The following result is immensely useful. Theorem 5 (Euclid’s Algorithm). Let a and b be integers, not both zero; and let g = gcd(a, b). Also let S = {ma + nb : m, n ∈ Z}. Then S = {kg : k ∈ Z}. In particular, there exist integers m, n such that g = ma + nb. Proof. Let x = ma + nb ∈ S. Since g a and g b, it follows that g divides ma + nb = x, i.e. x ∈ {kg : k ∈ Z}. We have shown the easy direction S ⊆ {kg : k ∈ Z}, and now we must prove containment in the reverse direction. Let P be the set of positive elements of S. Observe that P is nonempty. (If a > 0 then a = 1·a + 0·b ∈ P . If a < 0 then |a| = (−1)·a + 0·b ∈ P . So if a 6= 0, then P is nonempty. A similar argument applies if b 6= 0.) Since N is well ordered, we may take d to be the least element of P , i.e. d is the least positive element of S. By definition, d = ma + nb for some m, n ∈ Z. We first show that d a. By the Division Algorithm, there exist q, r ∈ Z such that a = qd + r, 0 ≤ r < d. Thus r = a − qd = (1 − qm)a − qnb ∈ S. Since r < d where d is the least positive element of S, r cannot be positive. We must have r = 0, i.e. d a as claimed. Similarly, d b. Hence d is a common divisor of a and b. Since g is the greatest common divisor of a and b, we must have d ≤ g. On the other hand, g a and g b implies that g divides ma + nb = d. This forces g = d. Consequently, g = d = ma + nb ∈ S. Moreover, for every k ∈ Z we have kg = (km)a + (kn)b ∈ S. Thus {kg : k ∈ Z} ⊆ S and the result follows. Note that the m and n in the latter result are not unique. For example gcd(12, 18) = 6 which may be written as 6 = 2·12 − 18 = −12 + 1·18 = 5·12 − 3·18 = · · · . Once again, the name of the latter theorem is a slight misnomer: the actual algorithm for computing g = gcd(a, b), due to Euclid, is known as Euclid’s Algorithm or the Euclidean Algorithm. This algorithm amounts to repeated application of the Division Algorithm. The Extended Euclidean Algorithm does a little more: it actually finds m and n such that ma + nb = g. Following standard terminology from linear algebra, we refer to integers 3 of the form ma + nb as integer linear combinations of a and b. In this language, we seek to compute g, and to express it as an integer linear combination of a and b. Here is an example illustrating this algorithm: Example: and 72. Solution: Compute g = gcd(98, 72) and express g as an integer linear combination of 98 98 = 1·72 + 26 72 = 2·26 + 20 26 = 1·20 + 6 20 = 3·6 + 2 6 = 3·2 + 0 It is easy to see that gcd(98, 72) = 2, the last nonzero remainder. (Every common divisor of 98 and 72 must divide 26, and consequently must also divide 20, and 6, and 2. Conversely, every integer dividing 2 must divide both 98 and 72.) To express 2 as an integer linear combination of 98 and 72, solve for 2 by reversing the steps above: 2 = 20 − 3·6 = 20 − 3·(26 − 20) = 4·20 − 3·26 = 4·(72 − 2·26) − 3·26 = 4·72 − 11·26 = 4·72 − 11·(98 − 72) = 15·72 − 11·98. Thus gcd(98, 72) = 2 = (−11)·98 + 15·72. (At this point, you should check: (−11)·98 + 15·72 = −1078 + 1080 = 2.) Alternative Solution: The following approach uses shorthand matrix notation for keeping track of linear combinations of 98 and 72 along the way. Each row (x, y, z) in the table represents the relation 98x + 72y = z. 98 72 1 0 0 1 1 −1 −2 3 3 −4 −11 15 36 −49 98 72 26 20 6 2 0 We do not actually need the last row, only the previous row, corresponding to the last nonzero remainder; this gives gcd(98, 72) = 2 = (−11)·98 + 15·72. 4 Here is an interpretation of the computation above: If currency exists only in bills worth $98 and $72, then the possible monetary transactions are those in amounts which are multiples of $2. To pay $2, simply give fifteen $72-bills, and take back eleven $98-bills in change. More generally, if currency exists only in bills worth $a and $b, then the possible monetary transactions are those in amounts which are multiples of $g, where g = gcd(a, b). Writing g as an integer linear combination of a and b tells us how to transact $g. A more serious application of Euclid’s Algorithm is the following: Theorem 6 (Euclid’s Lemma). If a prime p divides ab, then either p a or p b. (Note the inclusive ‘or’: it is possible that p divides both Proof. Suppose that p ab but p 6 a; we must show that a and b.) p b in this case. Since the only divisors of p are ±1 and ±p, but ±p are not divisors of a, the only common divisors of a and p are ±1. Thus gcd(a, p) = 1 = ma + np for some m, n ∈ Z. Since p divides both ab and p, we see that p divides m(ab) + (nb)p = (ma + np)b = b as required. The same argument gives the following more general result: Theorem 7. If n divides ab where gcd(a, n) = 1, then n b. Proof. Since gcd(a, n) = 1, there exist integers x, y such that ax + ny = 1. Now n divides both ab and n, so n divides (ab)x + n(by) = (ax + ny)b = b as required. An important consequence of Euclid’s Lemma is the Fundamental Theorem of Arithmetic: Every positive integer is uniquely expressible as a product of primes. For a proof of this result, see the previous handout on Mathematical Induction. Practice Problems 1. In each of the following cases, divide a by d, giving the quotient q and remainder r. (a) (b) (c) (d) (e) (f) a = 45, d = 17; a = −45, d = 17; a = 12345, d = 23456; a = 123, d = 123; a = 999, d = 10100−1; a = 1017 −1, d = 10100 −1. 5 2. In each of the following cases, find g = gcd(a, b); also find integers m, n such that g = ma + nb. (a) (b) (c) (d) (e) (f) a = 26, b = 16; a = 123, b = 456; a = 3114, b = 6702; a = 4718, b = 4719; a = 128, b = 256; a = 0, b = 45. 3. Complete the proof of Theorem 4 by showing that if m is even and n is odd, then m+n is odd. 4. Prove that for every odd integer n, the number n3 −n is divisible by 24. 5. Find all integers x such that 11x ≡ 30 mod 73. 6. Suppose that ax+by = 6 where a, b, x, y ∈ Z. What can you conclude about gcd(a, b)? or about gcd(x, y)? 7. Show that there are no integers satisfying 26x ≡ 19 mod 102. 6