3.2 The Extended Euclidean Algorithm

The Euclidean Algorithm computes greatest common divisors quickly, but also, with only slightly more work, yields a very useful fact: gcd(a, b) can be expressed as a linear combination of a and b. That is, there exist integers x and y such that gcd(a, b)=ax+by. For example,

1=gcd(45, 13)=45(2)+1377=gcd(259, 119)=259611913.

The Extended Euclidean Algorithm will tell us how to find x and y. Rather than give a set of equations, we’ll show how it works with the two examples we calculated in Subsection 3.1.3.

When we computed gcd(12345, 11111),  we did the following calculation:

12345=111111+123411111=91234+51234=2465+45=14+1.

For the Extended Euclidean Algorithm, we’ll form a table with three columns and explain how they arise as we compute them.

We begin by forming two rows and three columns. The first entries in the rows are the original numbers we started with, namely 12345 and 11111. We will do some calculations so that we always have

entry in first column =12345x+11111y, 

where x and y are integers. The first two lines are trivial: 12345=112345+011111 and 11111=012345+111111:

x y
12345 1 0
11111 0 1

The first line in our gcd(12345, 11111) calculation tells us that 12345=111111+1234. We rewrite this as 1234=12345111111. Using this, we compute

(1st row) 1(2nd row), 

yielding the following:

x y
12345 1 0
11111 0 1
1234 1 1 (1st row) 1(2nd row).

In effect, we have done the following subtraction:

12345=12345(1)+11111(0)1111=12345(0)+11111(1)_1234=12345(0)+11111(1).

Therefore, the last line tells us that 1234=123451+11111(1).

We now move to the second row of our gcd calculation. This says that 11111=91234+5,  which we rewrite as 5=1111191234. This tells us to compute (2nd row) 9(3rd row). We write this as

x y
12345 1 0
11111 0 1
1234 1 1
5 9 10 (2nd row) 9(3rd row).

The last line tells us that 5=12345(9)+1111110.

The third row of our gcd calculation tells us that 4=12342465. This becomes

x y
12345 1 0
11111 0 1
1234 1 1
5 9 10
4 2215 2461 (3rd row) 246(4th row).

Finally, we obtain

12345 1 0
11111 0 1
1234 1 1
5 9 10
4 2215 2461
1 2224 2471 (4th row) (5th row).

This tells us that 1=12345(2224)+111112471.

Notice that as we proceeded, we were doing the Euclidean Algorithm in the first column. The first entry of each row is a remainder from the gcd calculation, and the entries in the second and third columns allow us to express the number in the first column as a linear combination of 12345 and 11111. The quotients in the Euclidean Algorithm tell us what to multiply a row by before subtracting it from the previous row.

Let’s do another example using 482 and 1180 and our previous calculation that gcd(1180, 482)=2:

x y
1180 1 0
482 0 1
216 1 2 (1st row) 2(2nd row)
50 2 5 (2nd row) 2(3rd row)
16 9 22 (3rd row) 4(4th row)
2 29 71 (4rd row) 3(5th row).

The end result is 2=1180(29)+48271.

To summarize, we state the following.

Theorem

Let a and b be integers with at least one of a, b nonzero. There exist integers x and y,  which can be found by the Extended Euclidean Algorithm, such that

gcd(a, b)=ax+by.

As a corollary, we deduce the lemma we needed during the proof of the uniqueness of factorization into primes.

Corollary

If p is a prime and p divides a product of integers ab,  then either p|a or p|b. More generally, if a prime p divides a product abz,  then p must divide one of the factors a, b, , z.

Proof. First, let’s work with the case p|ab. If p divides a,  we are done. Now assume pa. We claim p|b. Since p is prime, gcd(a, p)=1 or p. Since pa,  the gcd cannot be p. Therefore, gcd(a, p)=1,  so there exist integers x, y with ax+py=1. Multiply by b to obtain abx+pby=b. Since p|ab and p|p,  we have p|abx+pby,  so p|b,  as claimed.

If p|abz,  then p|a or p|bz. If p|a,  we’re done. Otherwise, p|bz. We now have a shorter product. Either p|b,  in which case we’re done, or p divides the product of the remaining factors. Continuing in this way, we eventually find that p divides one of the factors of the product.

The property of primes stated in the corollary holds only for primes. For example, if we know a product ab is divisible by 6, we cannot conclude that a or b is a multiple of 6. The problem is that 6=23,  and the 2 could be in a while the 3 could be in b,  as seen in the example 60=415. More generally, if n=ab is any composite, then n|ab but na and nb. Therefore, the primes, and 1, are the only integers with the property of the corollary.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset