Section 2

advertisement
1
Chapter 5: Divisibility and the Greatest Common Divisor
Practice HW p. 34 # 1, 4, Additional Web Exercises
The Greatest Common Divisor of Two Positive Integers
Definition: The greatest common divisor of two positive integers a and b , denoted as
gcd( a, b) , is the largest positive integer that divides a and b with no remainder.
Examples: gcd( 20,30) 
gcd( 72, 108) 
How do we find the greatest common divisor of larger numbers?
Elementary Method for Computing the gcd of Two Numbers
Decompose each number into its prime factors. The gcd is obtained by multiplying the
prime factors the two numbers have in common. If the two numbers have no common
prime factors, then the gcd = 1.
Example 1: Find the gcd(360, 540).
Solution:
█
How do we find the greatest common divisor of very large integers?
Division algorithm: Let m be a positive integer ( m  0 ) and let b be any integer. Then
there is exactly one pair of integers q (called the quotient) and r (called the remainder)
such that
b  qm  r where 0  r  m .
2
Example 1: Find the quotient q and remainder r and illustrate the division algorithm
when computing 20021  41 .
Solution:
█
The Euclidean Algorithm
The Euclidean Algorithm makes repeated use of the division algorithm to find the greatest
common divisor of two numbers. Let a and b be positive integers where a  b , If b | a ,
then gcd( a, b)  b . If b | a , we apply the division algorithm as follows:
a  q1b  r1
b  q2 r1  r2
r1  q3r2  r3
r2  q4 r3  r4

rn  3  qn 1rn  2  rn 1
rn  2  qn rn 1  rn  gcd( a , b)
rn 1  qn 1rn  0
The process ends when a remainder of zero is obtained. The last nonzero remainder, rn , is
the greatest common divisor of a and b, that is, gcd( a, b)  rn .
3
Note: If we set a  r1 and b  r0 , the Euclidean Algorithm can be generalized as
ri 1  qi 1  ri  ri 1
0  ri 1  ri
Example 2: Use the Euclidean Algorithm to determine the gcd( 360, 540) .
Solution:
█
Example 3: Use the Euclidean Algorithm to determine the gcd( 52598, 2541) .
Solution:
█
4
Example 4: Use the Euclidean Algorithm to determine the gcd( 3854682, 1095939) .
Solution:
█
Note: The number of divisions needed to compute the gcd(a, b) in the Euclidean
Algorithm is no more than 5 times the number of decimal digits for b.
For example, when we found gcd( 3854682, 1095939) , b = 1095939 has 7 digits. Thus,
the
Maximum Number of Division Steps  5  7  35 steps (Actually only took 4)
5
Proof that the Euclidean Algorithm Produces the gcd(a, b)
To show that rn , the last non-zero remainder, is, the gcd(a, b) for a  b , we must show
the following steps:
1. rn | a and rn | b ( rn is a divisor of both a and b).
2. rn is the largest common divisor of a and b.
3. rn will always exist, that is, we are guaranteed to have a remainder of 0 in the
Euclidean Algorithm.
Proof Step 1: Given
a  q1b  r1
b  q2 r1  r2
r1  q3r2  r3
r2  q4 r3  r4

rn  3  qn 1rn  2  rn 1
rn  2  qn rn 1  rn
rn 1  qn 1rn  0
6
Proof Step 2: Given
a  q1b  r1
b  q2 r1  r2
r1  q3r2  r3
r2  q4 r3  r4

rn  3  qn 1rn  2  rn 1
rn  2  qn rn 1  rn
rn 1  qn 1rn  0
Proof Step 3: For each step of the Euclidean Algorithm
ri 1  qi 1  ri  ri 1
0  ri 1  ri
█
7
Least Common Multiple of Two Numbers
Definition: The least common multiple of two positive integers a and b, denoted as
lcm(a, b), is the smallest positive integers that both a and b divide evenly. In
mathematical terms, we say that l  lcm ( a, b) , if
1. a | l and b | l .
2. If a | k and b | k , then l  k .
Examples: lcm (10, 25) 
lcm (15, 20) 
Fact: If k is a positive integer where a | k and b | k , then for l  lcm ( a, b) , not only does
l  k but also l | k . (Proof Additional Exercise)
Note: The least common multiple is used to find the least common denominator when
adding or subtracting fractions.
How is the greatest common divisor related to the least common multiple? The following
theorem answers that question.
Theorem: lcm ( a, b) 
a b
gcd( a, b)
Proof: We first need a preliminary fact that we will be able to prove in Chapter 7, which
says:
If m | nk and gcd ( m, n )  1 , then m | k .
Suppose l  lcm ( a, b) and g  gcd ( a, b) . Hence
l  x1a and l  x2b since a | l and b | l
a  y1g and b  y2 g since g | a and g | b
We claim that gcd ( y1, y2 )  1 , for if not, there exists a common divisor d  1 of y1 and
y2 where d | y1 and d | y2 , which says that
y1  c1d and y2  c2d
But
a  y1g  c1dg  c1 (dg ) and b  y2 g  c2dg  c2 (dg ) ,
which says that dg | a and dg | b . This contradicts the fact that g  gcd ( a, b) ( dg  g )
Continued on Next Page
8
Since l  x1a and l  x2b , we have
x1a  x2b
x1( y1g )  x2 ( y2 g )
(Recall a  y1g and b  y2 g )
x1 y1  x2 y2
(Cancel g’s)
Hence, y1 | x2 y2 . Since gcd ( y1, y2 )  1 , the preliminary fact says that y1 | x2 . Thus, by
a
divisibility, it follows that x2  t y1 . Hence, using the fact that a  y1g or y1  , we
g
have
l  x2 b  (t y1 )b  t
a
b.
g
Hence,
l  lcm (a, b)  t
ab
ab
.
t
g
gcd( a, b)
Now, l  lcm ( a, b) is the smallest positive integer that both a and b divide. This implies
that t  1. Hence
lcm ( a, b) 
ab
gcd( a, b)
and the proof is complete.
█
Example 5: Find the lcm (3854682, 1095939) .
Solution:
█
9
Maple Commands for Computing the Greatest Common Divisor of Two Numbers
> igcd(360, 540);
> igcd(52598, 2541);
> igcd(3854682, 1095939);
Maple Commands for Computing the Least Common Multiple of Two Numbers
> ilcm(3854682, 1095939);
10
11
12
13
14
15
Download