3 Euclidean Lecture
3 Euclidean Lecture
3 Euclidean Lecture
Lecture 3
Justin Stevens
1 Euclidean Algorithm
Greatest Common Divisor
Proof
GCD of 3 Numbers
Euclidean Algorithm Challenges
2 Bezout’s Identity
3 Linear Congruences
We can find the set of all positive divisors of the number n, denoted D(n):
We can find the set of all positive divisors of the number n, denoted D(n):
We can find the set of all positive divisors of the number n, denoted D(n):
We can find the set of all positive divisors of the number n, denoted D(n):
Around the time of 300 BC, a great Greek mathematician rose from
Alexandria by the name of Euclid. He wrote a series of 13 books known as
Elements. Elements is thought by many to be the most successful and
influential textbook ever written. It has been published the second most of
any book, next to the Bible.
The book covers both Euclidean geometry and elementary number theory.
This chapter will focus solely on Book VII, Proposition 1.
“When two unequal numbers are set out, and the less is
continually subtracted in turn from the greater, if the number
which is left never measures the one before it until a unit is left,
then the original numbers are relatively prime." - Euclid
490 = 110 · 4 + 50
110 = 50 · 2 + 10
50 = 10 · 5.
D(490) = {1, 2, 5, 7, 10, 14, 35, 49, 70, 98, 245, 490}
D(110) = {1, 2, 5, 10, 11, 22, 55, 110}
D(50) = {1, 2, 5, 10, 25, 50}.
Theorem. For two natural a, b, a > b, to find gcd(a, b) we use the division
algorithm repeatedly
a = bq1 + r1
b = r1 q2 + r2
r1 = r2 q3 + r3
···
rn−2 = rn−1 qn + rn
rn−1 = rn qn+1 .
Example 1.
(a) Find gcd(603, 301).
(b) Find gcd(289, 153).
(c) Find gcd(2627, 481).
(d) Find gcd(8774, 1558).
∗
Source: 2002 HMMT
Justin Stevens Euclidean Algorithm (Lecture 3) 16 / 43
Exponent GCD
Note the parallel between the above equations and computing gcd(64, 40):
5
Note that 34 − 1 | 34 − 1, hence gcd(320 − 1, 34 − 1) = 34 − 1.
Notice the parallel with the division algorithm:
64 = 20 · 3 + 4
20 = 4 · 5.
1 Euclidean Algorithm
2 Bezout’s Identity
Euclidean Algorithm Recap
Proof
Bezout’s Identity Puzzles
3 Linear Congruences
Theorem. For two natural a, b, a > b, to find gcd(a, b) we use the division
algorithm repeatedly
a = bq1 + r1
b = r1 q2 + r2
r1 = r2 q3 + r3
···
rn−2 = rn−1 qn + rn
rn−1 = rn qn+1 .
65 = 45 · 1 + 20
45 = 20 · 2 + 5
20 = 5 · 4
5 = 45 − 20 · 2
= 45 − (65 − 45 · 1)2
= 45 · 3 − 65 · 2.
Express 5 as Linear Combination
65 = 45 · 1 + 20
45 = 20 · 2 + 5
20 = 5 · 4
5 = 45 − 20 · 2
= 45 − (65 − 45 · 1)2
= 45 · 3 − 65 · 2.
380 = 110 · 3 + 50
110 = 50 · 2 + 10
50 = 10 · 5
10 = 110 − 50 · 2
= 110 − (380 − 110 · 3) · 2
= 7 · 110 − 2 · 380.
a = dq + r , 0 ≤ r < d.
a = dq + r , 0 ≤ r < d.
d1 | ax1 + by1 = d.
d1 | ax1 + by1 = d.
Example 6. Suppose you have a 5 litre jug and a 7 litre jug. We can
perform any of the following moves:
Fill a jug completely with water.
Transfer water from one jug to another, stopping if the other jug is
filled.
Empty a jug of water.
The goal is to end up with one jug having exactly 1 litre of water. How do
we do this?
Note that at every stage, the jugs will contain a linear combination of 5 and
7 litres of water. We find that 1 = 5 · 3 + 7 · (−2), therefore, we want to fill
the jug with 5 litres 3 times, and empty the one with 7 litres twice.
Note that at every stage, the jugs will contain a linear combination of 5 and
7 litres of water. We find that 1 = 5 · 3 + 7 · (−2), therefore, we want to fill
the jug with 5 litres 3 times, and empty the one with 7 litres twice.
In order to keep track of how much water we have in each step, we use an
ordered pair (a, b), where a is the amount in the 5 litre jug and b is the
amount in the 7 litre jug:
Fill Transfer Transfer Transfer Empty
(0, 0) → (5, 0) → (0, 5) → (5, 5) → (3, 7) → (3, 0)
Transfer Fill Transfer Empty
(3, 0) → (0, 3) → (5, 3) → (1, 7) → (1, 0).
Jug Puzzle
Note that at every stage, the jugs will contain a linear combination of 5 and
7 litres of water. We find that 1 = 5 · 3 + 7 · (−2), therefore, we want to fill
the jug with 5 litres 3 times, and empty the one with 7 litres twice.
In order to keep track of how much water we have in each step, we use an
ordered pair (a, b), where a is the amount in the 5 litre jug and b is the
amount in the 7 litre jug:
Fill Transfer Transfer Transfer Empty
(0, 0) → (5, 0) → (0, 5) → (5, 5) → (3, 7) → (3, 0)
Transfer Fill Transfer Empty
(3, 0) → (0, 3) → (5, 3) → (1, 7) → (1, 0).
c(ax ) + c(by ) = c.
1 Euclidean Algorithm
2 Bezout’s Identity
3 Linear Congruences
Diophantine Equations
Modular Inverses
Example 9. How many ways are there to make $3.00 using dimes and
quarters?
Example 10. Find all pairs of integers x , y such that 5x + 7y = 1.
Example. How many ways are there to make $3.00 using dimes and quarters?
Let the number of dimes be d and quarters be q. Then,
(d, q) = (0, 12), (5, 10), (10, 8), (15, 6), (20, 4), (25, 2), (30, 0).
× 0 1 2 3 4 5 6
0 0 0 0 0 0 0 0
1 0 1 2 3 4 5 6
2 0 2 4 6 1 3 5
3 0 3 6 2 5 1 4
4 0 4 1 5 2 6 3
5 0 5 3 1 6 4 2
6 0 6 5 4 3 2 1
× 0 1 2 3 4 5 6
0 0 0 0 0 0 0 0
1 0 1 2 3 4 5 6
2 0 2 4 6 1 3 5
3 0 3 6 2 5 1 4
4 0 4 1 5 2 6 3
5 0 5 3 1 6 4 2
6 0 6 5 4 3 2 1
× 0 1 2 3 4 5
0 0 0 0 0 0 0
1 0 1 2 3 4 5
2 0 2 4 0 2 4
3 0 3 0 3 0 3
4 0 4 2 0 4 2
5 0 5 4 3 2 1
71 = 13 · 5 + 6
13 = 6 · 2 + 1
In reverse:
1 = 13 − 6 · 2
= 13 − (71 − 13 · 5) · 2
= 13 · 11 − 71 · 2.