1 MATH 212
Elementary Number Theory
Lecture 9
2 2.4 The Euclidean Algorithm
• The Euclidean Algorithm is an efficient process to compute the
greatest common divisor (gcd) of two integers.
• This involves a repeated application of the Division Algorithm.
• The algorithm is named after the Greek mathematician Euclid,
who included it in BOOK VII of his extraordinary work, The
Elements.
3 Lemma If a =bq+r, then gcd(a, b) = gcd(b, r).
Proof:
Suppose gcd (a, b)=d. Then by definition d|a and d|b.
This implies d|(a-bq), i.e., d|r [as a=bq+r]
Thus d is a common divisor of both b and r. and so d|d′ where d′=gcd(b, r).
Similarly, d′=gcd(b, r) implies d′|b and d′|r.
Thus, d′|(bq+r), i.e., d′|a [as a=bq+r]
Hence, d′ is a common divisor of both a and b and so d′|gcd(a, b).
That is, d′|d.
Now d|d′ and d′|d implies d = d′, i.e., gcd(a, b) = gcd(b, r).
Remark: gcd(bq+r, b) = gcd(b, r).
4 Example
Let us compute gcd(120, 28).
By the Division Algorithm, 120 = 28∙4+8,
so gcd(120, 28) = gcd(28, 8).
Again by the Division Algorithm 28 = 8∙3+4,
so gcd(28, 8) = gcd(8, 4) = 4 as 4|8.
In short, gcd(120, 28) = gcd(120 - 28∙4, 28) = gcd(8, 28)
= gcd(8, 28 - 8∙3) = gcd(8, 4) = 4 as 4|8.
5 The Euclidean Algorithm
The Euclidean Algorithm may be described as follows:
Let a and b be two integers whose greatest common divisor is
desired. Since gcd(I a I, I b I)= gcd(a, b), we assume that a > b > 0.
The first step is to apply the Division Algorithm to a and b to get
a = q1 b + r1 where 0 ≤ r1 < b.
If r1 = 0, then b I a and gcd(a, b) = b.
When r1 ≠ 0, divide b by r1 to produce integers q2 and r2 satisfying
b = q2r1 + r2, where 0 ≤ r2 < r1.
If r2 = 0, then we stop; otherwise, divide r1 by r2 to obtain
r1 = q3r2 + r3, where 0 ≤ r3 < r2.
6 This division process continues and we get the decreasing sequence
of remainders: b = r0 > r1 > r2 > r3 > · · · ≥ 0.
Since the remainders are non-negative and getting smaller and
smaller, this sequence should eventually terminate (cannot contain
more than b integers) say, at the (n + l)th stage where rn+1 = 0.
Thus, the last two equations in the above procedure are:
rn-2 = qn∙ rn-1 + rn, where 0 ≤ rn < rn-1
& rn-1 = qn∙ rn + 0.
It then follows by the result of lemma and induction that
gcd(a, b) = gcd (a, r0) = gcd (r0, r1) = gcd (r1, r2) = …
= gcd (rn-1, rn) = gcd (rn, 0) = rn which is the last non-zero remainder.
7 Problems 2.4
Q2. Use the Euclidean Algorithm to obtain integers x and y
satisfying c) gcd(119, 272) = 119x+272y.
Solution: We first compute gcd(119, 272) by the Euclidean Algorithm.
272 = 119∙2 + 34
119 = 34∙3 + 17
34 = 17∙2 + 0
So, gcd(119, 272) = last non-zero remainder = 17.
Next, using backward substitution in the above equations, we have
gcd(119, 272) = 17
= 119 - 34∙3
= 119 – (272 - 119∙2)∙3
= 119∙7 – 272∙3
= 119∙(7) + 272∙(-3)
which is in the form 119x+272y. Hence, x=7 and y= -3.
8 Theorem
If k > 0, then gcd(ka, kb) = k gcd(a, b).
Proof:
Let gcd(a,b) = d and gcd(ka, kb) = d′. Then d|a, and d|b.
This implies kd|ka and kd|kb. But d′ = gcd(ka, kb), therefore kd|d′.
Again as gcd(a,b) = d there exists x, y ∈ ℤ such that ax +by = d.
Thus, kax+kby = kd. Since d′ = gcd(ka, kb) so d′|ka, and d′|kb and
hence, d′| (kax+kby). That is d′| kd.
From the relations kd|d′ and d′| kd it follows that d′ = kd.
That is gcd(ka, kb) =k gcd(a, b).
9 Q4. Assuming that gcd(a, b)=1, prove the following:
b) gcd(2a+b, a+2b) = 1 or 3.
Solution:
Let d = gcd(2a+b, a+2b). Then by definition of gcd
d|(2a+b) and d|(a+2b)
Hence d|[2(2a+b) - (a+2b)] and d|[2(a+2b) - (2a+b)]
That is d|3a and d|3b.
This means d is a common divisor of 3a and 3b.
d|gcd(3a, 3b).
Since gcd(3a, 3b) = 3∙gcd(a, b) = 3∙1 = 3.
So, d|3, and hence d = 1 or 3.
10
d) gcd(a+b, a2-ab+b2) = 1 or 3.
Solution:
We note that a2-ab+b2 = (a+b)2 – 3ab
Hence, gcd(a+b, a2-ab+b2) = gcd(a+b, (a+b)2 – 3ab) = gcd(a+b, -3ab)
Since gcd(a+b, a) = gcd(b, a) = 1
And gcd(a+b, b) = gcd(a, b) = 1
So, gcd(a+b, -3ab) = gcd(a+b, -3) = 1 or 3.
Thus gcd(a+b, a2-ab+b2) = gcd(a+b, -3ab) = 1 or 3.
11 Q5. For positive integers a, b and n ≥ 1, show that
a) If gcd(a, b) = 1, then gcd (an, bn) =1
Solution:
Assume gcd(a, b) = 1, then by Bézout Identity, there exist integers x
and y such that ax+by = 1.
Raising power 2n-1 on both sides, we have (ax+by)2n-1 = 1
Expanding by Binomial expression, we have
2𝑛−1 2𝑛−1 2𝑛−2 2𝑛−1 𝑛 𝑛−1
𝑎𝑥 + 1
𝑎𝑥 𝑏𝑦 + ⋯ + 𝑛−1
𝑎𝑥 𝑏𝑦 +
2𝑛−1 𝑛−1 𝑛 2𝑛−1 2𝑛−2 2𝑛−1
𝑛
𝑎𝑥 𝑏𝑦 + ⋯+ 2𝑛−2
(𝑎𝑥) 𝑏𝑦 + 𝑏𝑦 = 1.
Out of the total 2n terms in the expansion, the first n terms are
divisible by an, and the last n terms are divisible by bn. It follows that
there are integers u and v such that an u + bn v = 1.
Thus, gcd (an, bn) = 1.
12 Q5. For positive integers a, b and n ≥ 1, show that
a) If gcd(a, b) = 1, then gcd (an, bn) =1
Solution:
Assume gcd(a, b) = 1, then by Bezout identity, there exist integers x
and y such that ax+by = 1.
Raising power 2n-1 on both sides, we have (ax+by)2n-1 = 1
Expanding by Binomial expression, we have
2𝑛−1 2𝑛−1 2𝑛−2 2𝑛−1 𝑛 𝑛−1
𝑎𝑥 + 1
𝑎𝑥 𝑏𝑦 + ⋯ + 𝑛−1
𝑎𝑥 𝑏𝑦 +
2𝑛−1 𝑛−1 𝑛 2𝑛−1 2𝑛−2 2𝑛−1
𝑛
𝑎𝑥 𝑏𝑦 + ⋯+ 2𝑛−2
(𝑎𝑥) 𝑏𝑦 + 𝑏𝑦 = 1.
Out of the total 2n terms in the expansion, the first n terms are
divisible by an, and the last n terms are divisible by bn. It follows that
there are integers u and v such that an u + bn v = 1.
Thus, gcd (an, bn) = 1.
13 b) The relation an | bn implies a | b
Solution:
Suppose d = gcd(a, b), then a = rd and b=sd where gcd(r, s)=1.
By part a) gcd(r, s)=1 implies gcd(rn, sn)=1.
Now assume an | bn. Then bn = an k for some integer k.
(sd)n = k (rd)n which simplifies to sn = krn
𝑠 𝑛
Or = 𝑘, an integer
𝑟
Since gcd(r, s)=1, so the above equation is true only when r=1.
Hence, the equation a=rd becomes a=d.
Consequently, the equation b=sd becomes b=sa which implies a|b.
Practice Questions
Problems 2.4
Q 1 – 7.
14 THANK YOU