200 likes | 422 Views
The Integers and Division. Outline. Division: Factors, multiples Exercise 2.3 Primes: The Fundamental Theorem of Arithmetic. The Division Algorithm Greatest Common Divisors: Relatively prime Least Common Multiples Modular Arithmetic: Congruence Applications of Congruence: Cryptology.
E N D
Outline • Division:Factors, multiples • Exercise 2.3 • Primes:The Fundamental Theorem of Arithmetic. • The Division Algorithm • Greatest Common Divisors:Relatively prime • Least Common Multiples • Modular Arithmetic:Congruence • Applications of Congruence:Cryptology
Division • DefinitionLet a and b be integers with a0. Then, we say that adivides b (and we note a | b) if there is an integer c such that b = ac. • a is called a factor of b, and b is multiple of a. • We note a ¬| b when a does not divide b • I used above notation for lack of strike vertical in PP. • Examples 3 | 12, but 3 ¬| 14 • Note P(a, b): a | b is a predicate, with values True or False. • Theorem Let a, b, c be integers with a 0. Then, • if a | b and a | c, then a | (b+c); • if a | b, then a | bc; • if a | b and b | c, then a | c.
Primes • DefinitionA positive integer pgreater than 1 is called primeif the only positive factors of p are 1 and p. • A positive integer that is greater than 1 and is not prime is called composite. • Examples 7 is prime. 9 is composite. • Note 1 is not prime, nor composite. • Some primes: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47… • The Fundamental Theorem of Arithmetic Every positive integer can be written uniquely as the product of primes, in increasing order. • Examples. 100 = 22 52, 641 = 641, 999 = 33 37, and 1024 = 210.
Primes – Cont. • TheoremIf n is a composite integer, then n has a prime divisor less than or equal to n. • An integer n is prime if it is not divisible by any prime less than or equal to n. • 101 is prime, since 101 is not divisible by 2, 3, 5, or 7 (the only primes less or equal than 101.) • Prime factorization of 7007: • Divide 7007 by primes, starting with 2, 3, 7… 7007/7 = 1001. • Divide 1001 by primes, starting with 7… 1001/7 = 143. • Divide 143 by primes, starting with 7… 143/11 = 13. • Stop, since 13 is prime. 7007 = 72 11 13
The Division Algorithm • The Division Algorithm Let a be an integer and d a positive integer. Then there are unique integers q and r, with 0 r < d, such that a = dq + r. • d is called the divisor, • a is called the dividend, • q is called the quotient, • r is called the reminder. • Examples 101 = 11 9 + 2. How about: 101 = 11 8 + 13? -11 = 3(-4) + 1. How about: -11 = 3(-3) - 2?
Greatest Common Divisors • Definition Let a and b be integers, not both zero. The largest integer d such that d | a and d | b , denoted by gcd(a, b), is called the greatest common divisor of a and b. • Examples gcd(24, 36) = 12. gcd(17, 22) = 1.
Greatest Common Divisors -Cont • Procedure to find gcd(a, b): • Find the prime factorization of a and b. • If a = p1a1p2a2… pnan, b = p1b1p2b2… pnbn, then gcd(a, b) = p1min(a1,b1)p2min(a2,b2) … pnmin(an,bn) • Examples 120 = 23 3 5 and 500 = 22 53 = 22 30 53 gcd(120, 500) = 22 30 51 = 20.
Relatively Prime Integers • Definition The integers a and b are relatively prime if gcd(a, b) = 1. • Example 17 and 22 are relatively prime. • Definition The integers a1, a2, …, an are pairwise relatively prime if gcd(ai, aj)=1 whenever 1i<jn. • Examples 10, 17 and 21 are pairwise relatively prime. 10, 17 and 24 are not pairwise relatively prime.
Least Common Multiples • Definition Let a and b be positive integers. The least common multiple of a and b is the smallest positive integer that is divisible by both a and b. It is denoted by lcm(a, b). • If a = p1a1p2a2… pnan, b = p1b1p2b2… pnbn, then lcm(a, b) = p1max(a1,b1)p2max(a2,b2) … pnmax(an,bn) • Example lcm(233572, 2433) = 243572. • Theorema +b + ab = gcd(a, b) lcm(a, b)
Modular Arithmetic • Definition Let a be an integer and m a positive integer. amodm denotes the reminder when a is divided by m. • amodm = r, where 0 r < m and a = qm + r. • Examples 17 mod 5 = 2 (since 17 = 3 5 + 2.) -133 mod 9 = 2 2001 mod 101 = 82 • The function fm: Z→ {0, 1, 2, …, m-1}, where fm(a) = amodm is onto, but not one-to-one.
Congruence • Definition If a and b are integers and m a positive integer, then a is congruent to b modulo m (ab (mod m)) if m divides (a – b). • Note ab (mod m) amodm = bmodm • Examples 17 5 (mod 6), since 17-5 = 12 = 6 2 is a multiple of 6. Note also that 17 mod 6 = 5 mod 6 = 5. 24 ¬ 14 (mod 6) • I used above notation for lack of strike in PP.
Congruence – Cont. • TheoremmZ+ aZ bZ ab (mod m) kZ a = b + km • Theorem If ab (mod m) andcd (mod m), then: a+c b+d (mod m), and ac bd (mod m).
Applications of Congruence • Hashing Functions • Pseudorandom Numbers • Linear congruential method • Cryptology • Caesar cipher
Hashing Functions • Records are identified by a key (integer k). • For example, using Social Security number • To record k, assign memory location • h(k) = kmodm, where m is the number of available memory locations. • h(k) is easily evaluated; it is also onto. • Example. If m=111, the record with k=064212848 is assigned to location 14 since h(064212848) = 064212848 mod 111 = 14. • Collision may occur since h(k) is not one-to-one. • Resolve by assigning next free location.
Pseudorandom Numbers • Linear congruential method • Choose: modulus m, multiplier a, increment c, and seed x0, with2 a < m, 0 c, x0 < m • Generate the sequence {xn} • xn+1 = (axn + c) modm. • Examplem = 9, a = 7, c = 4, and x0 = 3: • x1 = 7x0+4 mod 9 = 7 3 + 4 mod 9 = 25 mod 9 = 7 • x2=8, x3=6, x4=1, x5=2, x6=0, x7=4, x8=5, x9=3. • Usually, a pure multiplicative generator is used: • Increment c=0, modulus m=231 – 1, multiplier a=75=16,807.
Cryptology • Caesar’s encryption process: • Represent each letter by an integer from 0 to 25 • Replace a letter represented by p by the letter represented by f(p) = (p + 3) mod 26. • Example • M 12, f (12) = (12+3) mod 26 = 15 P • “Meet you in the park’’ is replaced by “Phhw brx lq wkh sdun” • Decryption. To recover the original message, use the inverse function f -1(p)= (p - 3) mod 26.
Cryptology – Cont. • Caesar cipher can be generalized: • Shift cipher: • f(p) = (p + k) mod 26. • Affine transformation: • f(p) = (ap + b) mod 26, where a and be are integers chosen so that f is a bijection. • Examplef(p) = (7p + 3) mod 26, K? • K 10, f (10) = (7 10 + 3) mod 26 = 73 mod 26 = 21 V. • K is replaced by V in the encrypted message.