4.5.2. Definition: Twin Primes. If p and p + 2 are both prime numbers, then p and p + 2 are called twin primes Examples: • Find all twin primes between 15 and 50. The primes 15 – 50 are: 17, 19, 23, 29, 31, 37, 41, 43, 47 Hence the twin primes between 1 and 50 are: 17, 19 • 29, 31 41, 43 Does 97 have a “twin” to form a pair of twin primes? No. Exercises: • Find all twin primes between 101 and 150. • Does 197 have a “twin” to form a pair of twin primes? WUCT121 Numbers 101 4.6. Greatest Common Divisor 4.6.1. Definition: Greatest Common Divisor Let a , b ∈ , with a ≠ 0 or b ≠ 0 . The greatest common divisor of a and b, denoted gcd(a, b), is a natural number c with the following properties: A. c is a common divisor of both a and b. That is c | a and c | b B. For all natural numbers d, if d is a common divisor of a and b, then d ≤ c . That is ∀d ∈ , ( d | a ∧ d | b ) ⇒ d | c Exercise: Write the definition of greatest common divisor using logic notation. WUCT121 Numbers 102 Examples: Evaluate: • gcd(18, 12) Factors of 18: 1, 2, 3, 6, 9, 18 Factors of 12: 1, 2, 3, 4, 6, 12 ∴ gcd(18,12) = 6 • gcd(18, –12) Factors of 18: 1, 2, 3, 6, 9, 18 Factors of –12: 1, 2, 3, 4, 6, 12 ∴ gcd(18,12) = 6 Note: need only consider positive factors since gcd is a natural number Exercises: • Evaluate gcd(45, 75) • Evaluate gcd(7, 11) WUCT121 Numbers 103 If a = p1α1 p 2 α 2 p 3α 3 ... p k α k and b = p1 β1 p 2 β 2 p 3 β3 ... p k β k , then gcd( a , b ) = 1 × p1 min(α1 , β1 ) p 2 min(α 2 , β 2 ) ... p k min(α k , β k ) where α i ≠ 0 and β i ≠ 0 Example: • gcd(3220, 1155) 3220 = 2 2 × 5 × 7 × 23 1155 = 3 × 5 × 7 ×11 gcd(2772, 2310) = 1 × 5 × 7 = 35 • gcd(35100, 6975) 35100 = 2 2 × 3 × 5 2 ×117 6975 = 3 2 × 5 2 × 31 gcd(35100, 6975) = 1 × 3 × 5 2 = 75 WUCT121 Numbers 104 Exercises: • Evaluate gcd(2772, 2310). • Evaluate gcd(6615, 1352). • If gcd(a , b ) = c , what are gcd(a , − b ), gcd(−a , − b ), gcd(−a , b ) ? • For a , b ∈ , with a ≠ 0 or b ≠ 0 , does gcd(a, b) always exist? Is it unique? • gcd(0, 0) is not defined. Why? WUCT121 Numbers 105 4.7. Least Common Multiple 4.7.1. Definition: Least Common Multiple Let a , b ∈ , with a ≠ 0 or b ≠ 0 . The least common multiple of a and b, denoted lcm(a, b), is a natural number c with the following properties: A. c is a common multiple of both a and b. That is a | c and b | c B. For all natural numbers d, if d is a common multiple of a and b, then c ≤ d . That is ∀d ∈ , ( a | d ∧ b | d ) ⇒ c | d Exercise: Write the definition of least common multiple using logic notation. WUCT121 Numbers 106 Example: Evaluate: • lcm(9, 15) Multiples of 9: 9, 18, 27, 36, 45,…. Multiples of 15: 15, 30, 45…. ∴ lcm(9,15) = 45 • lcm(32, –24) Multiples of 32: 32, 64, 96, 128,…. Multiples of –24: 24, 48, 72, 96,…. ∴ lcm(32, − 24) = 96 Note: Need only consider positive multiples since lcm is a natural number Exercise: • Evaluate lcm(45, 75) • Evaluate lcm(7, –11) WUCT121 Numbers 107 If a = p1α1 p 2 α 2 p 3α 3 ... p k α k and b = p1 β1 p 2 β 2 p 3 β3 ... p k β k , then lcm( a , b ) = p1max(α1 , β1 ) p2 max(α 2 , β 2 ) ... pk max(α k , β k ) . Example: Evaluate: • lcm(3220, 1155) 3220 = 22 × 5 × 7 × 23 1155 = 3 × 5 × 7 ×11 lcm( 2772, 2310) = 22 × 3 × 5 × 7 ×11 × 23 = 106260 • lcm(35100, 6975) 35100 = 22 × 3 × 52 ×117 6975 = 32 × 52 × 31 lcm(35100, 6975) = 22 × 32 × 52 × 31 ×117 = 3264300 WUCT121 Numbers 108 Exercise: • Evaluate lcm(2772, 2310). • Evaluate lcm(6615, 1352). • If lcm( a , b ) = c , what are lcm( a , − b ), lcm( −a , − b ), lcm( −a , b ) ? • For a , b ∈ , with a ≠ 0 or b ≠ 0 , does lcm(a, b) always exist? Is it unique? WUCT121 Numbers 109 4.8. The Euclidean Algorithm The Euclidean Algorithm is an efficient process for finding the greatest common divisor of two integers. It uses the Quotient-Remainder Theorem and the following lemmas: Lemma 1: gcd(r , 0) = r If r is a positive integer, then gcd(r , 0) = r . Proof: Let r ∈ , r > 0 , and let c = r. Clearly, c | r and c | 0 . Obviously, any other divisor of r (all of which also divide 0) must divide c as c = r. That is ∀d ∈ , ( d | r ∧ d | 0) ⇒ d | c ∴ gcd(r , 0) = c = r . WUCT121 Numbers 110 Lemma 2: a = bq + r ⇒ gcd(a , b ) = gcd(b, r ) If a , b ∈ , b ≠ 0 and q, r ∈ that a = b × q + r , then gcd(a , b ) = gcd(b, r ) . Proof: The proof of this lemma has two parts: a. Prove that gcd(a , b ) | gcd(b, r ) ; and b. Prove that gcd(b, r ) | gcd(a , b ) . Once we have shown these two results and noting that the greatest common divisor is always positive, we can conclude that gcd(a , b ) = gcd(b, r ) . A. Prove that gcd(a , b ) | gcd(b, r ) . Let gcd(a , b ) = k ∈ . Then k | a and k | b ; that is, ∃m, n ∈ , (a = km ∧ b = kn ) (1) . We are given that a = b × q + r , r > 0 (2) , Substituting (1) into (2), we have km = knq + r ⇒ km − knq = r ⇒ r = k (m − nq ) WUCT121 Numbers 111 Clearly, m − nq ∈ and so k | r . Therefore, k is a common divisor of b and r. So k | gcd (b, r ) , that is, gcd(a , b ) | gcd(b, r ) . B. Prove that gcd(b, r ) | gcd(a , b ) . Let gcd(b, r ) = l ∈ . Then l | b and l | r ; that is, ∃m, n ∈ , (b = lm ∧ r = ln ) (3) . We are given that a = b × q + r , r > 0 (4) . Substituting, (3) into (4), we have a = lmq + ln ⇒ a = l (mq + n ) . Clearly, mq + n ∈ and so l | a . Therefore, l is a common divisor of a and b. So l | gcd(a , b ) , that is, gcd(b, r ) | gcd(a , b ) . Therefore, by A. and B. gcd(a , b ) = gcd(b, r ) . WUCT121 Numbers 112 4.8.1. Process: The Euclidean Algorithm The Euclidean Algorithm is used to find gcd(a, b) and can be described as follows: 1. Let a , b ∈ , with | a |>| b |≥ 0 . 2. If b = 0, then gcd(a , b ) = a (by Lemma 1). If b ≠ 0 , apply the quotient remainder theorem to get a = bq + r , where 0 ≤ r < b , then, (by Lemma 2) gcd(a , b ) = gcd(b, r ) . Repeat the process in step 2, to find gcd(b, r ) (i.e. let a = b and b = r). The process is guaranteed to terminate eventually with r = 0 because each new remainder is less than the preceding one and all are nonnegative. Note if a < 0 or b < 0 then let a = | a |, b =| b | in the above algorithm WUCT121 Numbers 113 Examples: Find the greatest common divisor of the following pairs of numbers using the Euclidean Algorithm: • 2772 and 2310 Divide 2772 by 2310 to find : 2772 = 2310 × 1 + 462 Hence gcd(2772,2310) = gcd(2310,462) Divide 2310 by 462 to find : 2310 = 462 × 5 + 0 Hence gcd(2310,462) = gcd(462,0) = 462 Therefore gcd(2772,2310) = gcd(2310,462) = gcd(462,0) = 462 WUCT121 Numbers 114 • –243 and 223 gcd(−243,223) = gcd(243,223) Divide 243 by 223 to find : 243 = 223 × 1 + 20 Hence gcd(243,223) = gcd(223,20) Divide 223 by 20 to find : 223 = 20 × 11 + 3 Hence gcd(223,20) = gcd(20,3) Divide 20 by 3 to find : 20 = 3 × 6 + 2 Hence gcd(20,3) = gcd(3,2) Divide 3 by 2 to find : 3 = 2 ×1 + 1 Hence gcd(3,2) = gcd(2,1) Divide 2 by 1 to find : 2 = 1× 2 + 0 Hence gcd(2,1) = gcd(1,0) =1 Therefore gcd(−243,223) = gcd(243,223) = gcd(223,20) = gcd(20,3) = gcd(3,2) = gcd(2,1) = gcd(1,0) =1 WUCT121 Numbers 115 Exercises: Find the greatest common divisor of the following pairs of numbers using the Euclidean Algorithm: • 15 and 10 • 5 and 9 WUCT121 Numbers 116 • 90 and –54 • 24 and 63 WUCT121 Numbers 117 4.8.2. Definition: Relatively Prime If a , b ∈ and gcd(a , b ) = 1 then a and b are relatively prime. Example: gcd(17,9 ) = 1, therefore 17 and 9 are relatively prime Exercises: • Which of these pairs are relatively prime? ∗ 3, 8 ∗ 27, 32 ∗ 81, 33 ∗ 72, 139 • True or False? If true, what is y? If false, give a counterexample ∀x ∈ , ∃y ∈ , gcd( x, y ) = 1 • Let p be prime, n ∈ . What are the two possibilities for gcd( p, n ) ? WUCT121 Numbers 118 4.8.3. Theorem: Linear Combination of gcd If a , b ∈ and not both equal zero, then gcd(a , b ) exists and there exist m, n ∈ such that gcd(a , b ) = ma + nb . Note. The theorem says two things: • gcd(a , b ) always exists (as long as a and b are not both zero) and • gcd(a, b ) can be written as a linear combination of a and b. Corollary 1: If a and b are relatively prime, gcd (a , b ) = 1. Thus ∃m, n ∈ such that gcd(a , b ) = 1 = ma + nb . Corollary 2: ∀a , b, c ∈ , if gcd (a , b ) = 1 and a | bc , then a | c . WUCT121 Numbers 119 Proof: We must prove that: ∀a , b, c ∈ , ((gcd(a , b ) = 1 ∧ a | bc ) ⇒ a | c ) . We know: gcd(a , b ) = 1 that is ∃m, n ∈ such that 1 = ma + nb (1) and a | bc , that is ∃k ∈ such that bc = ka (2) . We must prove that a | c , that is, we must find l Œ Ÿ such that c = la . Multiplying (1) by c we have c = mac + nbc (3) . Substituting (2) into (3) c = mac + nqa = (mc + nq )a = la where l = mc + nq ∈ ∴a | c WUCT121 Numbers 120