Class Notes for Discrete Math I (Rosen)

advertisement
Class Notes for Discrete Math I (Rosen)
4.3: PRIMES AND GREATEST COMMON DIVISORS
Definition:
 pZ+ is prime if it has exactly two positive divisors.
 nZ+ is composite if it has more than two positive divisors.
Lemma: If nZ+ is composite, then there is a prime p such that
p | n.
Theorem (Euclid): There are infinitely many primes.
The Fundamental Theorem of Arithmetic: Every positive
integer greater than 1 can be uniquely written as the product of
prime numbers.
Example 1: Find the prime factorization of
(a) 6 (b) 10! (c) 437 (d) 521
Theorem: If n is composite, then n has a prime divisor less than
or equal to n .
Definition: Given a,bZ such that both are not zero.
 cZ+ is called a common divisor of a and b if c | a and c | b.
 Let cd(a,b) be the set of all common divisors of a and b.
 c is called a greatest common divisor of a and b if
(1) ccd(a,b) and
(2) If dcd(a,b), then d | c.
121
Class Notes for Discrete Math I (Rosen)
Theorem: The greatest common divisor of a and b is unique.
In set notation,
 cd(a,b) = { cZ+ | c | a  c | b }
 gcd(a,b) = max{ cZ+ | c | a  c | b }
Example 3:
(a) cd(12,18) = {1, 2, 3, 6}  gcd(12,18) = 6
(b) For mZ+, what is gcd(1,m) and gcd(0,m)?
(c) For primes p,qP, what is gcd(p,q)?
Definition: m,nZ are relatively prime if gcd(m,n) = 1.
Example 4: 7 and 15 are relatively prime.
Basic Definitions:
(a) m div n = m/n
(b) m mod n = m – n m/n
(c) gcd(m,n) = max{cZ+ | c|m  c|n}
(d) gcd(n,0) = n for any nZ+
The Division Algorithm: m = n (m div n) + (m mod n).
Lemma: If mZ and nZ+, then
gcd(m,n) = gcd(n,m mod n).
122
Class Notes for Discrete Math I (Rosen)
Example 5: Use the lemma to calculate gcd(294,105).
The Extended Euclidean Algorithm: Given mZ and nZ+,
there exist unique integers s,tZ such that gcd(m,n) = s m + t n.
Procedure: Form the following sequences (three of which are
recursively defined).
(1) a0 = m, a1 = n, and ai = ai–2 mod ai–1 for i  2.
(2) qi = ai–1 div ai for i  1.
(3) s0 = 1, s1 = 0, and si = si–2 – qi–1 si–1 for i  2.
(4) t0 = 0, t1 = 1, and ti = ti–2 – qi–1 ti–1 for i  2.
Sequences terminate for the smallest integer k  2 such that ak+1
= 0, implying that gcd(m,n) = ak, s = sk, and t = tk.
123
Class Notes for Discrete Math I (Rosen)
Example 6: Apply the Extended Euclidean Algorithm to m =
2487 and n = 2233.
i
gcd(ai,ai+1)
ai
qi
si
ti
0
1
2
3
4
5
6
7
8
9
124
Class Notes for Discrete Math I (Rosen)
Proof of the Extended Euclidean Algorithm:
i
gcd(ai,ai+1)
ai
0 gcd(a0,a1) (=gcd(m,n)) a0 (= m)
1
gcd(a1,a2)
a1 (= n)
2
gcd(a2,a3)
a2
3
gcd(a3,a4)
a3



qi
si
ti
- s0 (=1) t0 (=0)
q1 s1 (=0) t1 (=1)
q2
s2
t2
q3
s3
t3



k
qk
gcd(ak,0)
ak
sk
tk
Section 4.1, Example 6 (Generalized Shift Cipher):
Encryption: Let f (p) = (7p + 3) mod 26.
Decryption: Find constants c,d  Z26 such that
f –1(p) = (c p + d) mod 26.
c and d must satisfy
(1) 7c  1 (mod 26), and
(2) 3c + d  0 (mod 26).
i
0
1
2
3
4
gcd(ai,ai+1)
gcd(26,7)
ai
26
7
qi
-
si
1
0
ti
0
1
Properties:
(a+b) mod m = (a mod m + b mod m) mod m
(ab) mod m = (a mod m)(b mod m) mod m
a  b (mod m)  a mod m = b mod m
a  b (mod m)  (a – b)  0 (mod m)
125
Class Notes for Discrete Math I (Rosen)
Definition: Given a,bZ such that both are not zero.
 mZ+ is called a common multiple of a and b if
a | m and b | m.
 Let cm(a,b) be the set of all common multiples of a and b.
 m is called a least common multiple of a and b if
(1) mcm(a,b) and
(2) If ncm(a,b), then m | n.
Theorem: The least common multiple of a and b is unique.
In set notation,
 cm(a,b) = { mZ+ | a | m  b | m }
 lcm(a,b) = min{ mZ+ | a | m  b | m }
Example 7:
(a) cm(4,6) = {12, 24, 36, 48, …}  lcm(4,6) = 12
(b) For mZ+, what is lcm(1,m)?
(c) For p,qP, what is lcm(p,q)?
Theorem: Let m,nZ+. Then mn = gcd(m,n)  lcm(m,n).
126
Download