



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Lecture notes for Access 2011
The Euclidean Algorithm is a set of instructions for finding the greatest common divisor of any two positive integers. Its original importance was probably as a tool in construction and measurement; the algebraic problem of finding gcd(a, b) is equivalent to the following geometric measuring problem: Given two different rulers, say of lengths a and b, find a third ruler which is as long as possible, but so that you can still use it as a scale on both of the longer rulers. Thereās a neat āmovieā demonstration of how the algorithm works geometrically, on the Wikipedia page for āEuclidean Algorithmā. Euclid probably wasnāt thinking about finding multiplicative inverses in modular arithmetic, but it turns out that if you look at his algorithm in reverse, thatās exactly what it does!
The Euclidean Algorithm makes repeated used of integer division ideas: We āknowā that if a and b are positive integers, then we may write
a b
= q + r b
where q is the quotient, and the remainder r satisfies 0 ⤠r < b. If we clear fractions, this is the equation a = bq + r.
We really do know that this last equation is possible: starting with (b)(0), then (b)(1) etc. we may subtract increasing multiples of b from a until what remains is a non-negative number less than b. And thatās actually the mathematical reason that the integer division fact we started with is true. (This procedure is called the division algorithm.)
Here is the algebraic formulation of Euclidās Algorithm; it uses the division algorithm successively until gcd(a, b) pops out:
Theorem 1 (The Euclidean Algorithm). Given two integers 0 < b < a, we make a re- peated application of the division algorithm to obtain a series of division equations, which eventually terminate with a zero remainder:
a = bq 1 + r 1 , 0 < r 1 < b,
b = r 1 q 2 + r 2 , 0 < r 2 < r 1 ,
r 1 = r 2 q 3 + r 3 , 0 < r 3 < r 2 , Ā· Ā· Ā·
rjā 2 = rjā 1 qj + rj , 0 < rj < rjā 1
rjā 1 = rj qj+1. The greatest common divisor gcd(a, b) of a and b is rj , the last nonzero remainder in the division process.
Letās look at an example of the Euclidean algorithm in action - itās really quick at finding gcdās when your two integers are large. We should be able to verify these steps with our scientific calculators:
Example 1. Find the gcd of 42823 and 6409.
Solution.
Therefore gcd(42823, 6409) = 17.
Why does the Euclidean Algorithm actually give the gcd? It seems kind of strange that we can get the gcd of two numbers a and b by looking at the gcdās of the subsequent remainder values. Letās look at successive equations in this process: From the first equation a = bq 1 + r 1 , we deduce that since the gcd divides a and b it must divide r 1. Similarly in the next equation b = r 1 q 2 + r 2 , the gcd divides b and r 1 , so it must also divide r 2. Thus the gcd(a, b) divides all the remainders, including the final non-zero one, rj. On the other hand, by working up from the last equation rjā 1 = rj qj+1 we deduce that rj divides rjā 1. From the second to last equation rj also divides rjā 2 , and working all the way back to the top we see that rj divides both a and b, so is a divisor. Putting our reasoning together, rj must be the greatest common divisor! But enough of these explanations, letās try some exercises!
Exercise 1. Find the gcdās of the following pairs of numbers. Save your work because youāll need it later.
Example 3. Find the multiplicative inverse of 8 mod 11, using the Euclidean Algorithm.
Solution. Weāll organize our work carefully. Weāll do the Euclidean Algorithm in the left column. It will verify that gcd(8, 11) = 1. Then weāll solve for the remainders in the right column, before backsolving: 11 = 8 (1) + 3 3 = 11 ā 8(1) 8 = 3 (2) + 2 2 = 8 ā 3(2) 3 = 2 (1) + 1 1 = 3 ā 2(1) 2 = 1 (2) Now reverse the process using the equations on the right.
Therefore 1 ā” 8(ā4) mod 11, or if we prefer a residue value for the multiplicative inverse,
1 ā” 8(7) mod 11.
Be careful about the order of the numbers. We do not want to accidentally switch the bolded numbers with the non-bolded numbers!
Exercise 2. Find the greatest common divisor g of the numbers 1819 and 3587, and then find integers x and y to satisfy
1819 x + 3587y = g
Exercise 3. Find the multiplicative inverses of the following:
Exercise 4. Using the information from the previous exercise, solve the following equation for x and check your answer. 50 x ā” 63 mod 71.
Exercise 5. Solve 12345x ā” 6 mod 54321. Hint: First find the gcd.