Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Big O notation wikipedia , lookup
Approximations of π wikipedia , lookup
Proofs of Fermat's little theorem wikipedia , lookup
Halting problem wikipedia , lookup
Elementary mathematics wikipedia , lookup
Algorithm characterizations wikipedia , lookup
Factorization of polynomials over finite fields wikipedia , lookup
BEGliiEHS 5 CORNER E d i t e d by D M I T R i THORO San J o s e S t a t e C o l l e g e , San J o s e , California THE EUCLIDEAN ALGORITHM I 1. INTRODUCTION Consider the problem of finding the greatest common divisor of 34 and 144. The factorizations 34 = 2 • 17, 144 = 24 • 32 make this a trivial problem. However , this approach Is discouraging when one deals with, say., "long" Fibonacci numbers. Fortunately in Prop, 2 of Book VII, Euclid gave an elegant algorithm. As usual, we shall designate the g. c, d. of s and t by (s,t). 2. THE ALGORITHM The algorithm may be defined by the following flow chart. A ^ B means A replaces B, i. ee , set B = the current value of A. M represents the remainder in the division of K by L. I — K J —L W ->' K —L M—L /"~"^^^\Yes M = o? \ > (I,J) = L ->f Stop j 3z: L— K Flow Chart for Computing the G. C. D of Positive Integers I and J 53 BEGINNERS 1 CORNER 54 F o r I = 13 and J = 8, [Feb. the s u c c e s s i v e values of K, L , K L M 13 8 5 3 2 8 5 3 2 5 3 2 1 0 1 and M a r e : The l a s t value of L i s the d e s i r e d g.c.d. In the following computation, (10946, 2584) = the l a s t n o n - z e r o r e m a i n d e r . 4 2584)10946 10336 4 610|2584 2440 4 " 144(610 576 4 34J144 136 4 8|34 324 2|8" 8. 0 In this d i s c u s s i o n we shall e m p h a s i z e computational considerations. T h e r e a r e , however, n u m e r o u s " t h e o r e t i c a l ! t applications of the Euclidean A l gorithm. As LeVeque [1] e x p r e s s e s it, cative n u m b e r t h e o r y . " f? .. . it i s the c o r n e r s t o n e of m u l t i p l i - F o r a r e l a t e d t h e o r e m s e e Glenn Michael [ 2 ] , this issue. 3. A FORTRAN PROGRAM With an occasional glance at our flow c h a r t , it is e a s y to decipher the following F o r t r a n p r o g r a m . ( F o r t r a n i s a p r o b l e m - o r i e n t e d language commonly u s e d in c o n v e r s i n g with e l e c t r o n i c digital c o m p u t e r s . ) (i) A = B m e a n s A i s r e p l a c e d by B„ (ii) The READ and PUNCH s t a t e m e n t s r e f e r to c a r d input/output. (iii) In this context, N = K / L is an i n s t r u c t i o n to s e t N equal to [ K / L ] , i. e. , the g r e a t e s t Integer not exceeding K / L fixed point quotient). ( s o m e t i m e s called an i n t e g e r o r Thus if K = 13 and L = 3, N will equal 4. (iv) The symbol for multiplication i s an a s t e r i s k . 1964] BEGINNERS' CORNER (v) 55 A "conditional transfer' 1 is achieved by using an IF statement: if M < 0, go to statement 3 for the next instruction; otherwise go to statement 4. (vi) The FORMAT and END statements are technical requirements (which may be ignored). READ 10, I, J 10 FORMAT (315) K = I L = J 2 N = K/L M = K - L *N IF (M) 3, 3, 4 4K - L L = M GO TO 2 3 PUNCH 10, I, J, L END 4. Length of the Algorithm A natural question arises: What is the "length" of this algorithm? I. e. , if s and t are given, how many divisions are required to compute (s,t) via the Euclidean Algorithm? Let us designate this number by N(s,t). For convenience we may assume s > t. Thus for n > 1, N(n + l,n) = 2; the first division yields the remainder 1, whereas the second results in a zero remainder — signifying termination of the algorithm. (As a byproduct we see that any two consecutive integers are relatively prime.) In Part II we shall see how Fibonacci numbers (Fi = F ? = 1 , F., 1 = F. 1 L i+i i + F. .,) were used by Lame" to establish a remarkable result. Additional properties of N(s,t) are suggested in the following exercises. 5. El. EXERCISES Note that the Euclidean Algorithm applied to the positive integers s and t may be described by the equations BEGINNERS* CORNER 56 r 8 = 1%+ r l 9 0 2= xt < s t = rtq2 + r2s 0 < r2 < rj i + = ^ r 3» 0 < r3 < r2 = r , q + r .J n - 20 n-lTi n r . = r q ,n + 0 n-1 n TI+1 r 0 ^ r n Explain why we m u s t r e a c h a r e m a i n d e r b e r of s t e p s . E2. [Feb, 1964] < r n-1 (r - ) which i s z e r o In a finite n u m - Hint: Look at the i n e q u a l i t i e s . In E l , show that ( s , t ) = r (the l a s t n o n - z e r o remainder),, Use r e p e a t e d applications of P r o b l e m 1.3 Hint: [3], E3. (a) Verify that M = K - L * N i s the r e m a i n d e r in the division r e p r e s e n t e d by s t a t e m e n t 2 (N = K/L) of the F o r t r a n p r o g r a m . (b) Can the F o r t r a n p r o g r a m be u s e d to compute (I, J) when I < E4. P r o v e that if n ^ 3 , then N(n, 3) = 1, 2, o r 3. E5. Suppose that n > 5 i s chosen at r a n d o m . J? Find the probability that N(n,5) > 2. E6. P r o v e that for n > 3 , E7. F o r what values of n i s 3 < N(2n - 5,n) ^ 6? E8 8 Express E9. Investigate the following c o n j e c t u r e : If a - F K , then N(n,a) < K - 1. (F N(n + 3,n) = 2 5 3, or 4. .., F ) as a function of n. Can n be any positive i n t e g e r ? E10. number. Investigate the following c o n j e c t u r e : Let F ^ 2 b e any Fibonacci Then m a x N(n, F) = 1 + m a x (n, F - 1). REFERENCES 1. William J. LeVeque, Topics in Number T h e o r y , Addison-Wesley, Reading, M a s s . , 1 9 5 6 , Vol. I, Chap. 2. 2. Glenn Michael, "A New Proof for an Old P r o p e r t y , ! T Fibonacci Quarterly, Vol. 2 5 No. 1, F e b . 1964, p . 5 7 . 3. D. E. Thoro ? "Divisibility I , " Fibonacci Q u a r t e r l y , Vol. 1, No. 1, F e b . 1963, p. 5 1 .