4.4
The Greatest Common Divisor:
The Euclidean Algorithm
Discrete Mathematics
312706037 夏 旻
2023/11/27
2
Definition 4.2
For a, b ∈ Z, a positive integer c is said to be a
common divisor of a and b if c | a and c | b.
4.4 The Greatest Common Divisor: The Euclidean Algorithm
Definition 4.3
3
Example 4.32
The common divisors of 42 and 70 are 1, 2, 7, and 14, and
14 is the greatest of the common divisors.
4.4 The Greatest Common Divisor: The Euclidean Algorithm
Definition 4.3 (a)
c | a and c | b (that is, c is a common divisor of a, b)
Definition 4.3 (b)
for any common divisor d of a and b, we have d | c
4
Theorem 4.6
4.4 The Greatest Common Divisor: The Euclidean Algorithm
5
Theorem 4.6
4.4 The Greatest Common Divisor: The Euclidean Algorithm
6
Characteristics of greatest common divisor
4.4 The Greatest Common Divisor: The Euclidean Algorithm
7
Greatest common divisor and relatively prime
4.4 The Greatest Common Divisor: The Euclidean Algorithm
8
Example 4.33
Since gcd(42, 70) = 14, we can find x, y ∈ Z with
42x + 70y = 14, or 3x + 5y = 1. x = 2, y = −1 is a solution.
But for k ∈ Z, 1 = 3(2 − 5k) + 5(−1 + 3k),
so 14 = 42(2 − 5k) + 70(−1 + 3k),
the solutions for x = (2 − 5k), y = (−1 + 3k) are not unique.
4.4 The Greatest Common Divisor: The Euclidean Algorithm
9
Example 4.33
4.4 The Greatest Common Divisor: The Euclidean Algorithm
10
Euclidean Algorithm
4.4 The Greatest Common Divisor: The Euclidean Algorithm
11
Euclidean Algorithm
4.4 The Greatest Common Divisor: The Euclidean Algorithm
Definition 4.3 (b)
for any common divisor d of a and b, we have d | c
12
Euclidean Algorithm
4.4 The Greatest Common Divisor: The Euclidean Algorithm
Definition 4.3 (a)
c | a and c | b (that is, c is a common divisor of a, b)
13
Example 4.34
Find the greatest common divisor of 250 and 111, and express the result as a linear combination of these integers.
4.4 The Greatest Common Divisor: The Euclidean Algorithm
250 = 2(111) + 28,
111 = 3(28) + 27,
28 = 1(27) + 1,
27 = 27(1).
0 < 28 < 111
0 < 27 < 28
0 < 1 < 27
So 1 is the last nonzero remainder, Therefore
gcd(250, 111) = 1, and 250 and 111 are relatively prime.
14
Example 4.34
Find the greatest common divisor of 250 and 111, and express the result as a linear combination of these integers.
4.4 The Greatest Common Divisor: The Euclidean Algorithm
250 = 2(111) + 28,
111 = 3(28) + 27,
28 = 1(27) + 1,
27 = 27(1).
1 = (−1)(111) + 4[250 − 2(111)] = 4(250) − 9(111)
1 = 28 − 1[111 − 3(28)] = −1(111) + 4(28)
1 = 28 − 1(27)
This expression of 1 as a linear combination of 250 and 111 is not unique, for 1 = 250[4 − 111k] + 111[−9 + 250k], k ∈ Z.
(a/d)x + (b/d)y = 1
d = a(x − (b/d)k) + b(y + (a/d)k)
15
Example 4.37
Griffin has 2 unmarked containers. One holds 17 ounces of and the other holds 55 ounces. Show how to use containers to measure exactly one ounce.
From the Euclidean algorithm we find that
4.4 The Greatest Common Divisor: The Euclidean Algorithm
55 = 3(17) + 4,
17 = 4(4) + 1,
4 = 4(1).
0 < 4 < 17
0 < 1 < 4
Therefore, 1 = 17 − 4[55 − 3(17)] = 13(17) − 4(55).
16
4.4 The Greatest Common Divisor: The Euclidean Algorithm
Example 4.37
Consequently, Griffin must fill his smaller container 13 times and empty the contents into the larger container. Before he fills the 17-ounce one for the thirteenth time, Griffin has 12(17) − 3(55) = 204 − 165 = 39 ounces of water in the 55-ounce container.
After he fills the smaller container for the thirteenth time, he will empty 16 ounces from the smaller container, filling the larger container, Exactly 1 ounce will be left in the smaller container.
17
Example 4.38
Assisting students in programming classes, Brian finds that on the average he can help a student debug a Java program in 6 minutes, but it takes 10 minutes to debug a program written in C++. If he works continuously for 104 minutes and doesn’t waste any time, how many programs can he debug in each language?
4.4 The Greatest Common Divisor: The Euclidean Algorithm
18
Example 4.38
4.4 The Greatest Common Divisor: The Euclidean Algorithm
We seek x, y ≥ 0, where 6x + 10y = 104, 3x + 5y = 52.
As gcd(3, 5) = 1, we can write 1 = 3(2) + 5(−1), so 52 = 3(104) + 5(−52) = 3(104 − 5k) + 5(−52 + 3k) (by example 4.33), k ∈ Z. In order to obtain 0 ≤ x = 104 − 5k and 0 ≤ y = −52 + 3k, we must have (52/3) ≤ k ≤ (104/5). So k = 18, 19, 20 and there are
3 possible solutions:
The equation in Example 4.38 is an example of a Diophantine equation: a linear equation requiring integer solutions.
(a/d)x + (b/d)y = 1
d = a(x − (b/d)k) + b(y + (a/d)k)
19
Theorem 4.8
4.4 The Greatest Common Divisor: The Euclidean Algorithm
Definition 4.4
20
Example 4.39
4.4 The Greatest Common Divisor: The Euclidean Algorithm
21
Example 4.39
4.4 The Greatest Common Divisor: The Euclidean Algorithm
22
Theorem 4.9
4.4 The Greatest Common Divisor: The Euclidean Algorithm
23
Theorem 4.9
4.4 The Greatest Common Divisor: The Euclidean Algorithm
24
Theorem 4.10
4.4 The Greatest Common Divisor: The Euclidean Algorithm
Example 4.40
By virtue of theorem 4.10, we have the following:
25
Thank You
“