180 likes | 294 Views
CPTR311 Discrete Structures. Integers Reading: Kolman, Section 1.4. Divisibility. If one integer, n, divides into a second integer, m, without producing a remainder, then we say that “n divides m”. Denoted n | m
E N D
CPTR311Discrete Structures IntegersReading: Kolman, Section 1.4
Divisibility • If one integer, n, divides into a second integer, m, without producing a remainder, then we say that “n divides m”. • Denoted n | m • If one integer, n, does not divide evenly into a second integer, m, i.e., mn produces a remainder, then we say that “n does not divide m” • Denoted n | m
Some Properties of Divisibility • If n | m, then there exists a q such that m = qn • The absolute values of both q and n are less than the absolute value of m, i.e., |n| < |m| and |q| < |m| • Examples: 4 | 24: 24 = 46 and both 4 and 6 are less than 24. 5 | 135: 135 = 527 and both 5 and 27 are less than 135 • Simple properties of divisibility • If a | b and a | c, then a | (b + c) • If a | b and a | c, where b > c, then a | (b - c) • If a | b or a | c, then a | bc • If a | b and b | c, then a | c
Prime Numbers • A number p is called prime if the only positive integers that divide p are p and 1. • Examples of prime numbers: 2, 3, 5, 7, 11, and 13.
Factoring a Number into its Primes • Dividing a number into its multiples over and over again until the multiples cannot be divided any longer shows us that any number can eventually be broken down into prime numbers. • Examples: 9 = 33 = 3224 = 83 = 2223 = 233315 = 3105 = 3335 = 3357 = 3257 • Basically, this means that any number can be broken into multiples of prime numbers.
Factoring into Primes (continued) Each row of the table below presents a different number factored into its primes. The numbers in the columns represent the number of each particular prime can be factored out of each original value.
Factoring into Primes (continued) • Every positive integer n > 1 can be broken into multiples of prime numbers. • n = p1k1p2k2p3k3p4k4 …psksp1 < p2 < p3 < p4 < …< ps
Methods for Factoring • 2 | n If least significant digit of n is divisible by 2 (i.e., n is even), then 2 divides n • 3 | n If the sum of all the digits of n down to a single digit equals 3, 6, or 9, then 3 divides n. For example, is 17,587,623 divisible by 3? 1 + 7 + 5 + 8 + 7 + 6 + 2 + 3 = 39 3 + 9 = 12 1 + 2 = 3 YES! 3 divides 17,587,623
Methods for Factoring (continued) • Does 7 divide n? • Remove least significant digit (one’s place) from n and multiply it by two. • Subtract the doubled number from the remaining digits. • If result is divisible by 7, then original number was divisible by 7 • Repeat if unable to determine from result.
Methods for Factoring (continued) Examples of checking for divisibility by 7 • 1,876 187 – 12 = 175 17 – 10 = 7 • 4,923 492 – 6 = 486 48 – 12 = 36 • 34,461 3,446 – 2 = 3,444 344 – 8 = 336 33 – 12 = 21
Methods for Factoring (continued) • Does 11 divide n? • Starting with the most significant digit of n, adding the first digit, subtracting the next digit, adding the third digit, subtracting the fourth, and so on. If the result is 0 or a multiple of 11, then the original number is divisible by 11. • Repeat if unable to determine from result.
Methods for factoring (continued) Examples of checking for divisibility by 11 • 285311670611 2 – 8 + 5 – 3 + 1 – 1 + 6 – 7 + 0 – 6 + 1 – 1 = –11 • 279048 2 – 7 + 9 – 0 + 4 – 8 = 0
Methods for Factoring (continued) • Does 13 divide n? • Delete the last digit (one’s place) from n. • Subtract nine times the deleted digit from the remaining number. • If what is left is divisible by 13, then so is the original number. • Repeat if unable to determine from result.
Greatest Common Divisor • If a, b, and k are in Z+, and k | a and k | b, we say that k is a common divisor. • If d is the largest such k, d is called the greatest common divisor (GCD).
GCD Example Find the GCD of 540 and 315: • 540 = 22 33 5 • 315 = 32 5 7 • 540 and 315 share the divisors 3, 32, 5, 35, and 325 (Look at it as the number of possible ways to combine 3, 3, and 5) • The largest is the GCD 325 = 45 • 31545 = 7 and 54045=12
Euclidean Algorithm • The Euclidean Algorithm is a recursive algorithm that can be used to find GCD (a, b) • It is based on the fact that for any two integers, a > b, there exists a k and r such that: a = kb + r • Since if a | b and a | c, then a | (b + c), then we know that the GCD (a,b) must also divide r. Therefore, the GCD (a,b) = GCD(b,r)
Least Common Multiple • If a, b, and k are in Z+, and a | k, b | k, we say that k is a common multiple of a and b. • The smallest such k, call it c, is called the least common multiple or LCM of a and b • We write c = LCM(a,b)
Deriving the LCM • We can obtain LCM from a, b • For any integers a and b, we can write a = p1a1 p2a2 …pkak and b = p1b1 p2b2 …pkbk • LCM(a,b) = p1max(a1,b1) p2max(a2,b2) …pkmax(ak,bk)