Primes. The Fundamental Theorem of Arithmetic. CSI30 Prime Number - is a positive integer greater than 1 that is divisible only by 1 and itself. primes: 2, 3, 5, 7, 11, 13, 17, 19, 23, ... Composite Number – is a positive integer greater than 1, that is divisible by at least one more integer number other than 1 and itself. composites: 4, 6, 8, 9, 10, 12, 14, 15, .... In what sense are the primes the building blocks of positive integers? Prime Factorization of n A product of primes written that equals n, written in increasing order. 1 Primes. The Fundamental Theorem of Arithmetic. CSI30 In what sense are the primes the building blocks of positive integers? [Theorem 1] The Fundamental Theorem of Arithmetic Every positive integer greater than 1 has a unique prime factorization. 2 Primes. The Fundamental Theorem of Arithmetic. CSI30 How do you check if a number is prime? 3 Primes. The Fundamental Theorem of Arithmetic. CSI30 [Theorem 2] If n is a composite integer, then n has a prime divisor less than or equal to n. Example 3: Show that 103 is a prime number. Solution: 103≈10.15 Therefore the only possible divisors are 2, 3, 5, 7. 103 is not divisible by any of them. Thus 103 is a prime number. 4 Primes. The Fundamental Theorem of Arithmetic. CSI30 [Theorem 2] If n is a composite integer, then n has a prime divisor less than or equal to n . Proof: If n is composite, then (by the def. of composite number) n has a factor a, with 1< a < n. Therefore n = a b, where b Z+. Let's show that a n or b n : If both a > n and b > n , then ab > n n = n – which is a contradiction. Therefore, a n or b n and since a and b are divisors of n (they are its factors) we see that n has a positive divisor n . By the Fundamental Theorem of Arithmetic, this positive divisor is either prime or has a prime divisor less than itself. In either case, n has a prime divisor n . qed 5 Primes. The Fundamental Theorem of Arithmetic. CSI30 Extra! …. [Theorem 3] There are infinitely many primes Proof: (by contradiction) Let's assume that there is a finite number of primes, p1, p2, ..., pn Let q = p1 p2 ... pn + 1 By the Fundamental Theorem of Arithmetic, q is either a prime number or can be written as a product of two or more primes. None of the primes divide it, since if there is a prime pi that divides it (pi|q), then pi should divide (q - p1 p2 ... pn) , but q - p1 p2 ... pn = 1 and pi | 1. Thus, q is a prime number, and it is not from our list of n primes – contradiction. Our assumption was wrong, there are infinitely many primes. qed 6 Greatest Common Divisor (GCD) and Least Common Multiples (LCM) CSI30 [Def] Let a, b Z, a,b 0. The largest d Z such that d | a and d | b is called the greatest common divisor of a and b denotation: gcd(a,b) How to find GCD 1. find prime factorization of both a, and b 2. take the prime factors present in both factorization with their smallest powers (present in those factorization) 3. multiply Example 6: Find gcd(28,72). Solution: 28 = 22 7, 72 = 23 32 gcd(28,36) = 22 = 4. 7 Greatest Common Divisor (GCD) and Least Common Multiples (LCM) CSI30 Example 7: Find gcd(330,420). Solution: 330 = 2 3 5 11, 420 = 22 3 5 7 gcd(330,420) = 2 3 5 = 30. [Def] Two integers are relatively prime if their GCD is 1. Integers a1, a2, ..., an are pairwise relatively prime if gcd(ai,aj) = 1 for all pairs of i,j such that 1 i < j n Example 8: Determine if each of these sets are pairwise relatively prime a) 11, 15, 19 b) 14, 15, 21 8 The Euclidean Algorithm CSI30 The method describes an algoirthm for finding the GCD (using prime factorizations) is quite inefficient. Euclidean Algorithm gives a more efficient way of finding GCD. It is named after Greek mathematician Euclid. procedure gcd(a, b: positive integers) x := a y := b while y 0: r := x mod y x := y y := r {gcd(a,b) is x} This algorithm uses the following lemma: [Lemma 1] Let a=bq+r, where a,b,q, and r are integers. Then gcd(a,b) = gcd(b,r) 9 The Euclidean Algorithm CSI30 Example 4: find gcd(1001,1331) Solution: gcd(1001,1331) = gcd(1331,1001) – we prefer to take smaller as divisor and larger as dividend. 1331 =1 R 330 1001 Thus gcd(1331,1001) = gcd(1001,330) = gcd(330,11) = gcd(11,0) STOP 330 1001 =30 R 0 =3 R 11 11 330 Answer: gcd(1001,1331) = 11 10