30 likes | 157 Views
Divisors and GCD’s (2/5). For the record: Definition. We say a number d divides an integer n if there exists an integer k such that n = k d . In standard language, d “divides evenly” into n . The remainder r is 0.
E N D
Divisors and GCD’s (2/5) • For the record: Definition. We say a number ddivides an integer n if there exists an integer k such that n = k d . • In standard language, d “divides evenly” into n. The remainder r is 0. • We write d | n. This reads “d divides n”, i.e., “|” is a verb. • Definition. If n and m are integers, then the greatest common divisor d of n and mis the largest number which divides both n and m. • We write d = GCD(n, m). • Finally, if GCD(n, m) = 1, we say n and m are relatively prime.
How can you compute a GCD? • Worst way: Write down all the divisors of n and all the divisors of m and pick out the largest number which occurs on both lists. • Better way: Factor n and m into primes. The GCD will be all the primes that occur in both representations. (Problem: Factorization can be hard to do.) • Best way: The Euclidean Algorithm! This is repeated divisions as illustrated in the text and in class. • Example: Try to compute GCD(78, 585) with each of these methods.
About the EA (Euclidean Algorithm) • One can see that it produces a common divisor by running it backwards. • One can see that it produces the greatest common divisor by running it forwards. • One can see that it must terminate (i.e., reach a remainder of 0) since every remainder is positive and smaller than the previous remainder. • For Friday: • Hand-in #1 is due. • Read Chapter 5 and do Exercise 5.1, but also do them by the factorization method.