You are on page 1of 3
1. THE GREATEST COMMON DIVISOR If d and n are integers, then we say that d divides n if and only if there exists an integer q such that n= qd. Notice that if d divides n and m, then d also divides n +m and nm and an + bm for all integers ah Theorem 1. [fn and m are integers and m #0, then there exists an inteyer q such that n=gmtr where 0 0. ‘Then use induction on n. (Exercise) o A useful variation is the following result. Theorem 2. [fn and m are integers and m #0, then there exists an inteyer q such that n=qmir ‘where —|m|/2 |rg| > +++ we have that ri;1 = 0 for some positive integer k. Suppose that rky1 =Oand that rj 0 for ¢ < k. Then ged(ry,r1) = re. Tf one uses Theorem 2 then it is clear that Euclid’s algorithm is very fast. The number of divisions with remainder one has to do is roughly logy |ri|. (A similar bound also holds if fone uses Theorem | though). Proof. It is not hard to show that Euclid’s algorithm works. Note that ged(ria.ri) = ged(ri,res1) for all #, By induction on i one shows that ged(ro.r1) = ged(ri,riyt) for all i. In particular, ged (ro, 1) = ged(re, Tey4) Example 6. Euclid’s algorithm can be used to find integers 7 and y such that ged(n,m) = rn +-ym. Tt works as follows. First use Euclid’s algorithm to compute ged(n,m) and then work hack. For example, we alrendy saw that ged(9081,3270) = 3. We would like to find x and y such that 3 = 908Lr + 3270y. Now we work back in the computation of ged(9081, 3270). From (4) follows that. 35 (-1)-354417-21 From (3) follows that B= (-1) +3544 17- (729 — 2- B54) = 17-7204 (—1 — 17-2) B54 = 17-729 — 35-354. From (2) follows that = 17-729 —35- (3270 — 4-729) —35 +3270 + (17 435-4) +729 85 B270 + 157-729, and finally, from (1) follows that 3 = —85-3270 + 157- (9081 43-3270) = = —157- 9081 + (—35 + 3- 157) - 3270 = —157 - 9081 + 436-3270. ‘This method is sometimes called the extended Euclid’s algorithm, Algorithm 7. (Hxtended Euelid’s Algorithm) Let rp,1,..-srk "ey = as in Algorithm 5. Define ar, =O and 2,4 = and tis |. For i > 1, define 24, by induction by: see Sk — ek. ‘Then we have that ged(rasrs) = nigars + mire for i= 0,1,...,k. In particular, ged(ra.rt) = 2170 + x0rt Proof. Let i = k— j. We prove by induction on j that wed (rota) = an jeatnng +t yrhget For j = 0 we have to prove that ged(ro,.r1) = Lire + O- ray = re but this follows from Algorithm 5. Suppose that Bed(ro.ry) = Th jrTh-g FHI Tf we substitute, re yy = 1k yt qe-sre-y we obtain wed (ra.7y) = Taj H1T-§ + PelMF-1 — G-GTHD) = Fp prepa t (eases — Gest gly = Begg a tae sari ys ‘Theorem 8. Suppose that n anal m are integers. There exist integers x and y such that ged(nm) = an+ ym. Proof. ‘This follows from the extended Euclid’s Algorithm (Algorithm 7). If m and mare integers with ged(n,m) then we say that m and n are relatively prime, Corollary 9 [fa,n,m are integers and a divides both n and then a also divides ged(n,m). Proof. This follows immediately from the previous Theorem 8 o Example 10 (Putnam 2000). Prove that the expression selene) (") is an integer.

You might also like