Professional Documents
Culture Documents
Writeup On Euclidean Algorithm
Writeup On Euclidean Algorithm
Workshop
Euclidean Algorithm
In this workshop, we will study how to find the highest common factor of two large
whole numbers efficiently. Let us recall what you have learnt so far.
Notation 2
(i) We write a | b to mean that a is a factor of b.
(ii) We write a /| b to mean that a is not a factor of b.
This is an abbreviation to make it easier for us to discuss our ideas.
Example 3
(i) 2 | 6 because 6= 2 × 3 and 3 is an integer.
(ii) 3 | 141 because _______________________________________________
(iii) 4 /| 18 because _______________________________________________
Page 1-1
Primary Math Master Class Workshop: Euclidean Algorithm
Example 6
To find hcf (12,18 ) , we list the factors of each number.
Besides the listing method shown above, are there other methods for finding
hcf (12,18 ) ? Write them below:
Exercise 7
Find (i) hcf (3988,8973) , (ii) hcf ( 792,1547 ) .
Page 1-2
Primary Math Master Class Workshop: Euclidean Algorithm
Some of you probably find the above exercise tedious or difficult, using the methods
that you know so far:
Method 1: Listing the factors
Method 2: Find prime factorization of numbers
Method 3: Find common factors using synthetic division
These methods have limitations. They require you to know the prime factorization of
the numbers you are investigating. If the prime factors are large, you have to spend
a lot of time using trial and error. Is there a more efficient method?
We will now try to find another method. Before that, we make some observations.
Observation 8 Let a and b be integers. Then we can always find integers q and r
a bq + r and 0 ≤ r < b . We call b the divisor, q the quotient, r the
such that =
remainder.
Page 1-3
Primary Math Master Class Workshop: Euclidean Algorithm
a bq + r and 0 ≤ r < b .
Observation 11 Let a, b, q and r be integers such that =
Then hcf (a, b ) = hcf (b, r ) .
Proof:
Page 1-4
Primary Math Master Class Workshop: Euclidean Algorithm
Step 1: Divide a by b to get the first remainder r1 and the first quotient q1 ,
where=
a bq1 + r1 and 0 ≤ r1 < b . If r1 = 0 , we can stop the algorithm
=
and deduce that hcf =
(a, b ) hcf (b,0) b (Use Observation 11).
Otherwise, continue to Step 2.
Step 2: Divide b by r1 to get the next remainder r2 and the next quotient q2 ,
where=
b r1q2 + r2 and 0 ≤ r2 < r1 . If r2 = 0 , we can stop the algorithm
=
and deduce that hcf =
(a, b ) hcf =
(b, r1 ) hcf (r1,0) r1 (Use Observation
11). Otherwise, continue to Step 3.
Step 3: Divide r1 by r2 to get the next remainder r3 and the next quotient q3 ,
where=
r1 r2q3 + r3 and 0 ≤ r3 < r2 . If r3 = 0 , we can stop the algorithm
=
and deduce that hcf =
(a, b ) hcf =
(b, r1 ) hcf =
(r1, r2 ) hcf (r2 ,0) r2 (Use
Observation 11). Otherwise, continue to Step 4.
Page 1-5
Primary Math Master Class Workshop: Euclidean Algorithm
Thus, we can use Euclidean Algorithm to find the hcf of two numbers first before
finding their lcm using Result 15.
Page 1-6
Primary Math Master Class Workshop: Euclidean Algorithm
Reflections 18
(i) Does the Euclidean Algorithm involve more steps if we use large numbers?
(ii) Is the Euclidean Algorithm always more efficient than the other methods:
listing factors, prime factorization, synthetic division?
Page 1-7
Primary Math Master Class Workshop: Euclidean Algorithm
Problem Given a 3-litres jug and a 5-litres jug, how do we measure 1 litre of water
using just the two jugs? We only know the capacities of the jugs. There are no
additional markings on the jugs for us to measure 1 litre.
Solution
Using Euclidean Algorithm to find hcf ( 3,5 ) :
5 = 3 × 1 + 2........[1]
3 = 2 × 1 + 1.........[2]
1 =1× 2 + 0.........[3]
Now use [1], [2], [3] to get other relationships (this is called the Extended Euclidean
Algorithm):
From [2], 1 = 3 − 2 × 1.
Then use [1] to write 2 in terms of 3 and 5 (the jugs that you have):
1 = 3 − ( 5 − 3 × 1) × 1
1 = 3 × ( 2 ) + 5 × ( −1)
Now, the numbers inside the brackets give us a hint of how many times we pour
water into (+) the jug or out of (-) the jug. Initially, the 2 jugs are empty.
Step Action Amount of water Amount of water
in 3-litre jug in 5-litre jug
1 Fill up the 3-litre jug with water. (+) 3 litres 0 litres
2 Pour all the water from the 3-litre jug to 0 litres 3 litres
the 5-litre jug. Transfer costs nothing.
3 Fill up the 3-litre jug with water. (+) 3 litres 3 litres
4 Pour water from the 3-litre jug to the 5- 1 litre 5 litres
litre jug until the 5-litre jug is full.
Transfer costs nothing.
5 Pour away all the water from the 5-litre 1 litre 0 litres
jug. (-)
Now, you have 1 litre of water (in the 3-litre jug).
Page 1-8
Primary Math Master Class Workshop: Euclidean Algorithm
Exercise 19 Given a 13-litres jug and a 17-litres jug, how do we measure 1 litre of
water using just the two jugs? We only know the capacities of the jugs. There are no
additional markings on the jugs for us to measure 1 litre.
Is there another way to measure 1 litre of water using just the two jugs? Compare
your answer with your friend’s. If your answers differ, copy your friend’s answer
below.
Page 1-9
Primary Math Master Class Workshop: Euclidean Algorithm
=
Let x x=
2, y y 2 be another solution. Then _________________________ .
So, 13 x1 − 13 x2 = 17 y 2 − 17 y1
13 ( x1 − x2 =
) 17 ( y 2 − y1 )
Since hcf (13,17 ) = 1, we can use Euclid’s Lemma to deduce that 13 | ( y 2 − y1 ) , i.e.
y 2 − y1 =
13k , where k is an integer. So, y=
2 y1 + 13k .
Similarly, since hcf (13,17 ) = 1, we can use Euclid’s Lemma to deduce that
17 | ( x1 − x2 ) , i.e. x1 − x2 =
17m , where m is an integer. So, x=
2 x1 − 17m .
So,
13 x1 + 17 y1 − 13 × 17m + 17 × 13k =
1
1 − 13 × 17m + 17 × 13k =
1
17 × 13k =13 × 17m
k =m
Thus, given a particular solution=x x=
1, y =
y1 , the general solution is x x=
2, y y2 ,
where x=
2 x1 − 17k and y=
2 y1 + 13k and k is an integer. Different values of k give
Page 1-10
Primary Math Master Class Workshop: Euclidean Algorithm
Now, find out which value of k gives rise to your friend’s answer (if different from
yours).
Exercise 21
Determine whether each of the following Linear Diophantine equations has solutions.
If it has solutions, find the general solution.
(a) 6 x + 9 y =
14
(b) 6 x + 9 y =
21
Page 1-11
Primary Math Master Class Workshop: Euclidean Algorithm
Exercise 22
A zoo charges $10 for adult admissions and $8 for children admissions. On a
particular evening, the total receipts were $82. Given that there were more children
admissions than adult admissions, how many people visited the zoo?
Page 1-12