Prime Numbers. p 1 p 2 p n + 1.

Similar documents
Kevin James. MTHSC 412 Section 2.4 Prime Factors and Greatest Comm

The Prime Numbers. Definition. A prime number is a positive integer with exactly two positive divisors.

8 Primes and Modular Arithmetic

Continued Fractions and the Euclidean Algorithm

5544 = = = Now we have to find a divisor of 693. We can try 3, and 693 = 3 231,and we keep dividing by 3 to get: 1

GREATEST COMMON DIVISOR

CHAPTER 5. Number Theory. 1. Integers and Division. Discussion

8 Divisibility and prime numbers

MATH10040 Chapter 2: Prime and relatively prime numbers

U.C. Berkeley CS276: Cryptography Handout 0.1 Luca Trevisan January, Notes on Algebra

CS 103X: Discrete Structures Homework Assignment 3 Solutions

Today s Topics. Primes & Greatest Common Divisors

Lecture 13 - Basic Number Theory.

Primality - Factorization

MATH 289 PROBLEM SET 4: NUMBER THEORY

The Euclidean Algorithm

Chapter 11 Number Theory

Homework until Test #2

Some Polynomial Theorems. John Kennedy Mathematics Department Santa Monica College 1900 Pico Blvd. Santa Monica, CA

Number Theory. Proof. Suppose otherwise. Then there would be a finite number n of primes, which we may

The Factor Theorem and a corollary of the Fundamental Theorem of Algebra

15 Prime and Composite Numbers

Elementary Number Theory

GCDs and Relatively Prime Numbers! CSCI 2824, Fall 2014!

Grade 6 Math Circles March 10/11, 2015 Prime Time Solutions

Lectures on Number Theory. Lars-Åke Lindahl

CONTINUED FRACTIONS AND PELL S EQUATION. Contents 1. Continued Fractions 1 2. Solution to Pell s Equation 9 References 12

Session 6 Number Theory

WRITING PROOFS. Christopher Heil Georgia Institute of Technology

I. GROUPS: BASIC DEFINITIONS AND EXAMPLES

Some facts about polynomials modulo m (Full proof of the Fingerprinting Theorem)

Discrete Mathematics and Probability Theory Fall 2009 Satish Rao, David Tse Note 2

Math Review. for the Quantitative Reasoning Measure of the GRE revised General Test

Introduction. Appendix D Mathematical Induction D1

HOMEWORK 5 SOLUTIONS. n!f n (1) lim. ln x n! + xn x. 1 = G n 1 (x). (2) k + 1 n. (n 1)!

Notes on Factoring. MA 206 Kurt Bryan

Revised Version of Chapter 23. We learned long ago how to solve linear congruences. ax c (mod m)

Math Workshop October 2010 Fractions and Repeating Decimals

Handout #1: Mathematical Reasoning

Solving Linear Systems, Continued and The Inverse of a Matrix

Quotient Rings and Field Extensions

= = 3 4, Now assume that P (k) is true for some fixed k 2. This means that

CONTINUED FRACTIONS AND FACTORING. Niels Lauritzen

MATH 22. THE FUNDAMENTAL THEOREM of ARITHMETIC. Lecture R: 10/30/2003

How To Know If A Domain Is Unique In An Octempo (Euclidean) Or Not (Ecl)

11 Ideals Revisiting Z

MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS

Continued Fractions. Darren C. Collins

Theorem3.1.1 Thedivisionalgorithm;theorem2.2.1insection2.2 If m, n Z and n is a positive

MATH 13150: Freshman Seminar Unit 10

Lecture 3: Finding integer solutions to systems of linear equations

Systems of Linear Equations

3. Mathematical Induction

Primes in Sequences. Lee 1. By: Jae Young Lee. Project for MA 341 (Number Theory) Boston University Summer Term I 2009 Instructor: Kalin Kostadinov

it is easy to see that α = a

Number Theory Hungarian Style. Cameron Byerley s interpretation of Csaba Szabó s lectures

SECTION 10-2 Mathematical Induction

Elementary Number Theory and Methods of Proof. CSE 215, Foundations of Computer Science Stony Brook University

SUBGROUPS OF CYCLIC GROUPS. 1. Introduction In a group G, we denote the (cyclic) group of powers of some g G by

Discrete Mathematics, Chapter 4: Number Theory and Cryptography

The Division Algorithm for Polynomials Handout Monday March 5, 2012

An Introductory Course in Elementary Number Theory. Wissam Raji

The last three chapters introduced three major proof techniques: direct,

POLYNOMIAL FUNCTIONS

Handout NUMBER THEORY

SUM OF TWO SQUARES JAHNAVI BHASKAR

If A is divided by B the result is 2/3. If B is divided by C the result is 4/7. What is the result if A is divided by C?

MATH10212 Linear Algebra. Systems of Linear Equations. Definition. An n-dimensional vector is a row or a column of n numbers (or letters): a 1.

CONTENTS. Please note:

Working with whole numbers

Undergraduate Notes in Mathematics. Arkansas Tech University Department of Mathematics

DIVISIBILITY AND GREATEST COMMON DIVISORS

2.5 Zeros of a Polynomial Functions

a 11 x 1 + a 12 x a 1n x n = b 1 a 21 x 1 + a 22 x a 2n x n = b 2.

Notes on Determinant

Zeros of a Polynomial Function

CHAPTER 5 Round-off errors

Real Roots of Univariate Polynomials with Real Coefficients

SOLUTIONS FOR PROBLEM SET 2

Just the Factors, Ma am

WHAT ARE MATHEMATICAL PROOFS AND WHY THEY ARE IMPORTANT?

CHAPTER 3. Methods of Proofs. 1. Logical Arguments and Formal Proofs

Integer roots of quadratic and cubic polynomials with integer coefficients

SECTION 0.6: POLYNOMIAL, RATIONAL, AND ALGEBRAIC EXPRESSIONS

Chapter 4, Arithmetic in F [x] Polynomial arithmetic and the division algorithm.

z 0 and y even had the form

PYTHAGOREAN TRIPLES KEITH CONRAD

PROBLEM SET 6: POLYNOMIALS

PUTNAM TRAINING POLYNOMIALS. Exercises 1. Find a polynomial with integral coefficients whose zeros include

An Introduction to Number Theory Prime Numbers and Their Applications.

Cartesian Products and Relations

LEARNING OBJECTIVES FOR THIS CHAPTER

MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS. + + x 2. x n. a 11 a 12 a 1n b 1 a 21 a 22 a 2n b 2 a 31 a 32 a 3n b 3. a m1 a m2 a mn b m

TEXAS A&M UNIVERSITY. Prime Factorization. A History and Discussion. Jason R. Prince. April 4, 2011

Section 4.2: The Division Algorithm and Greatest Common Divisors

5.1 Radical Notation and Rational Exponents

Mathematical Induction

JUST THE MATHS UNIT NUMBER 1.8. ALGEBRA 8 (Polynomials) A.J.Hobson

ALGEBRAIC APPROACH TO COMPOSITE INTEGER FACTORIZATION

Math 4310 Handout - Quotient Vector Spaces

Transcription:

Prime Numbers 7-19-2006 A prime number is an integer n > 1 whose only positive divisors are 1 and n. An integer greater than 1 which is not prime is composite. Euclid showed that there are infinitely many primes. The Prime Number Theorem says that the number of primes less than or equal to a real number x is approximately x ln x. The Sieve of Eratosthenes finds prime numbers by trial division. Definition. An integer greater than 1 is prime if its only positive factors are 1 and itself. An integer greater than 1 which is not prime is composite. The prime numbers are the building blocks of the integers. I ll make this more precise later when I discuss the Fundamental Theorem of Arithmetic. Lemma. Every integer greater than 1 is divisible by at least one prime. Proof. I ll prove the result by induction. To begin with, the result is true for n = 2, since 2 is prime. Take n > 2, and assume the result is true for all integers greater than 1 but less than n. I want to show that the result holds for n. If n is prime, it s divisible by a prime namely itself! So suppose n is composite. Then n has a positive factor a other than 1 and n. Suppose n = ab. If a > n, then since b 1, I get n = ab > n 1 = n տր. Thus, a n, and since a n, I have in fact a < n. Since a 1, I get 1 < a < n. By the induction hypothesis, a has a prime factor p. But p a and a n implies p n, so n has a prime factor as well. This shows that the result is true for all n > 1 by induction. Theorem. (Euclid) There are infinitely many prime numbers. Proof. Suppose on the contrary that there are only finitely many primes p 1, p 2,..., p n. Look at p 1 p 2 p n + 1. This number is not divisible by any of the primes p 1, p 2,..., p n, because it leaves a remainder of 1 when divided by any of them. But the previous lemma says that every number greater than 1 is divisible by a prime տր. This contradiction implies that there can t be finitely many primes that is, there are infinitely many. If you are trying to factor a number n, you do not need to try dividing by all the numbers from 1 to n: It s enough to go up to n. This is the idea of the next lemma. Lemma. Every composite number has a proper factor less than or equal to its square root. Proof. Suppose n is composite. I can write n = ab, where 1 < a, b < n. If both a, b > n, then n = n n < a b = n.տր So at least one of a, b must be less than or equal to n. In fact, you can adapt the preceding proof to show that a composite number must have a prime factor less than or equal to its square root. 1

For an arbitrary number that is several hundred digits in length, it may be impossible with current technology to determine whether the number is prime. In fact, many cryptographic systems depend on the difficulty of factoring large numbers. Example. To see whether 127 is prime, I only need to see if it has a prime factor 127 11.27. You can do the arithmetic to verify that 127 isn t divisible by 2, 3, 5, 7, or 11. Hence, it must be prime. Example. (The Sieve of Eratosthenes) The sieve is a method for generating a list of primes by hand. Write down the integer beginning with 2. Go through the list, crossing out every integer divisible by 2. Then go through the list, crossing out every integer divisible by 3. Keep going. I ve illustrated the first two passes below. 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 By the square root criterion above, I ve already found all the primes less than 10, namely 2, 3, 5, and 7. After crossing out all the numbers divisible by 5, I ll have all the primes up to 25. And so on. Of course, more sophisticated sieve methods are used in practice. I showed above that there are infinitely many primes. How are they distributed? That is, are they evenly distributed, or do they get sparser as you look at bigger and bigger integers? The Prime Number Theorem gives an aymptotic estimate for π(x), the number of primes less than or equal to x. It says: π(x) lim x + x = 1. lnx The picture below was generated by Mathematica, the symbolic mathematics program. It shows the 2

graphs of π(x) and x lnx. 1200 1000 800 600 400 200 2000 4000 6000 8000 10000 x The graph of π(x) is on top and the graph of is on the bottom. lnx The Prime Number Theorem was first conjectured by Legendre and Gauss. The first rigorous proofs were given by Hadamard and de la Vallee Poussin around 1896. Elementary proofs were given by Atle Selberg and Paul Erdös in the 1930 s. On the other hand, there are lots of composite numbers around. For example, 1001! + 2, 1001! + 3, 1001! + 4,..., 1001! + 1001 is a run of 1000 consecutive composite numbers. You can use the same method to generate runs of composite numbers of any length. Example. Use the Prime Number Theorem to estimate the number of primes less than 1000000. By the Prime Number Theorem, π(1000000) 1000000 ln 1000000 72382. The actual number of primes less than 1000000 is π(1000000) = 78498. On the other hand, many problems concerning the distribution of primes are unsolved. For example, there are primes that come in pairs (two units apart), such as 11 and 13, or 71 and 73. These are called twin primes. Question: (Twin Prime Conjecture) Are there infinitely many twin primes? There are enormously large twin primes known. The largest known in 2001 were 318032361.2 107001 ± 1, which were discovered by David Underbakke and Phil Carmody. They are numbers having 32220 digits! The Twin Prime Conjecture is still unresolved: A proof was announced in 2004, but a gap was found, and the question remains open. c 2006 by Bruce Ikenaga 3

Greatest Common Divisors 7-19-2006 The greatest common divisor (m, n) of integer m and n is the largest integer which divides both m and n. The greatest common divisor can be found using the Euclidean algorithm, which is a process of repeated division. The greatest common divisor (m, n) of m and n is a linear combination of m and n. m and n are relatively prime if (m, n) = 1. Definition. The greatest common divisor of two integers (not both zero) is the largest integer which divides both of them. If a and b are integers (not both 0), the greatest common divisor of a and b is denoted (a, b). (In Britain, the greatest common divisor is often called the highest common factor.) Examples. (4, 6) = 2, (17, 17) = 17, (42, 0) = 42, (12, 15) = 3. Once and for all, in discussions of the greatest common divisor all the variables will denote integers, and it s understood that in (a, b) at least one of a and b is nonzero. Proposition. (a) (a, b) 1. (b) (a, b) = ( a, b ). (c) (a, 0) = a. Proof. (a) Since 1 a and 1 b, (a, b) must be at least as big as 1. (b) x a if and only if x a; that is, a and a have the same factors. But a is either a or a, so a and a have the same factors. Likewise, b and b have the same factors. Therefore, x is a common factor of a and b if and only if it s a common factor of a and b. Hence, (a, b) = ( a, b ). (c) (By the convention I stated earlier, when I write (a, 0) I m implying that a 0.) By (b), I have (a, 0) = ( a, 0). I have a 0, since a 0 = 0. Obviously, a a. Thus, a is a common divisor of a and 0. Therefore, it s less than or equal to the greatest common divisor, so a ( a, 0). However, ( a, 0) a, and since these are both positive numbers, I must have ( a, 0) a. Putting the two inequalities together, I have ( a, 0) = a. Together with my earlier equation I have (a, 0) = ( a, 0) = a. Definition. a and b are relatively prime if (a, b) = 1. For example, 49 and 54 are relatively prime, but 25 and 105 are not. ( m Proposition. If d = (m, n), then d, n = 1. d) Proof. Suppose m = da and n = db. Then ( m d, n = (a, b). d) 1

Suppose that p > 0 and p a, p b. Then I can find e and f such that a = pe and b = pf. Thus, m = dpe and n = dpf. This shows that dp is a common divisor of m and n. Since d is the greatest common divisor, d dp. Therefore, 1 p, so p = 1 (since p was a positive integer). I ve proven that 1 is the only positive common divisor of a and b. Therefore, 1 is the greatest common divisor of a and b: ( m d, n d) = (a, b) = 1. Proposition. (m, n) = (m + kn, n) for any integer k. Proof. First, if x is a common factor of m and n, then x m and x n. So x kn, and hence x m + kn. Thus, x is a common factor of m + kn and n. Conversely, if x is a common factor of m + kn and n, then x (m + kn) and x n. Therefore, x kn, so x [(m + kn) kn] = m. That is, x is a common factor of m and n. Since m, n and m + kn, n have the same set of common divisors, the two pairs must have the same greatest common divisor. Example. (42, 24) = 6, and if I add a multiple of 24 to 42, the greatest common divisor will still be 6. For instance, (42 + 5 24, 24) = (162, 24) = 6. The last result says that I don t change the greatest common divisor if I add or subtract multiples of one member of the pair from the other. This yields the following recursive procedure for computing the greatest common divisor. Euclidean Algorithm. Begin with a pair of nonnegative integers {m, n}, not both 0. (The absolute value property I stated earlier shows that there s no harm in assuming the integers are nonnegative.) 1. If one of the numbers is 0, the other is the greatest common divisor of the pair. (Stop.) 2. Otherwise, apply the Division Algorithm to write m = qn + r, where 0 r < n. 3. Replace the pair {m, n} with the pair {n, r}. 4. Go to step 1. At each step, both elements are 0, and each pass through step 3 decreases the second element. Since the second element always gets smaller, but can t be negative, Well-Ordering implies that algorithm must terminate in an {m, 0} pair (in step 2) after a finite number of steps. The preceding property shows that these steps produce new pairs of numbers with the same greatest common divisor as the previous pairs. Therefore, when the algorithm terminates, the greatest common divisor I ve found is the greatest common divisor of the original pair. Example. Use the Euclidean algorithm to compute (124, 348). Write the pair as {348, 124}. Equation Pair of numbers 2

346 = 2 124 + 100 {124, 100} 124 = 1 100 + 24 {100, 24} 100 = 4 24 + 4 {24, 4} 24 = 6 4 + 0 {4, 0} At this point, one of the numbers is 0, so the greatest common divisor is the other number: (348, 124) = 4. Example. You can also form the greatest common divisor of more than two numbers, in the obvious way. For instance, (42, 105, 91) = 7. Definition. If x and y are numbers, a linear combination of x and y (with integer coefficients) is a number of the form ax + by, where a, b Z. Example. 29 = 2 10 + 1 9 shows that 29 is a linear combination of 10 and 9. 7 = ( 2) 10 + 3 9 shows that 7 is a linear combination of 10 and 9 as well. The next result is extremely important, and is often used in proving things about greatest common divisors. Theorem. (m, n) is the smallest positive linear combination of m and n. In particular, there are integers a and b (not necessarily unique) such that (m, n) = am + bn. Example. I showed above that (348, 124) = 4. The theorem says that there are integers a and b such that 4 = a 348 + b 124. In fact, 4 = 5 348 + ( 14) 124. This combination is not unique. For example, 4 = 129 348 + ( 362) 124. I ll give a few easy corollaries before proving the theorem. Corollary. If d m and d n, then d (m, n). Proof. (m, n) = am + bn for some a, b Z. 3

Therefore, d m and d n, then d (am + bn = (m, n). This says that the greatest common divisor is not only greatest in terms of size; it s also greatest in the sense that any other common factor must divide it. Corollary. m and n are relatively prime if and only if am + bn = 1 for some a, b Z. Proof. ( ) Suppose m and n are relatively prime. Then (m, n) = 1. By the theorem, Therefore, ( ) Suppose (m, n) = am + bn for some a, b Z. am + bn = 1 for some a, b Z. am + bn = 1 for some a, b Z. This says that 1 is a positive linear combination of m and n, so (since 1 is the smallest positive integer) it s the smallest positive linear combination of m and n. By the theorem, this implies that 1 is the greatest common divisor, and m and n are relatively prime. Proof of the theorem. I ll use the Euclidean algorithm. The initial pair {m, n} consists of two numbers m and n. Each of these numbers is a linear combination of m and n. The only changes the algorithm makes are to switch the elements or to subtract a multiple of one element from the other. I have to show that neither changes the fact that the two elements are linear combinations of m and n. If two elements are each linear combinations of m and n, this obviously remains true if I the swap the elements. For subtracting a multiple, suppose I have the pair {x, y} = {am + bn, cm + dn}. I divide x by y: The new pair is x = qy + r, where 0 r < y. {y, r} = {y, x qy} = {cm + dn, (am + bn) q(cm + dn)} = {cm + dn, (a qc)m + (b qd)n}. Each element of this new pair is a linear combination of m and n. I know the algorithm terminates in {(m, n), 0}. It follows that (m, n) must be a linear combination of m and n. Now suppose p is a positive linear combination of m and n: p = am + bn for some a, b Z. (m, n) m and (m, n) n, so (m, n) p. Both of these numbers are positive, so (m, n) p. Since (m, n) is smaller than any positive linear combination of m and n, (m, n) must be the smallest positive linear combination of m and n. Example. (42, 105) = 21, so the theorem asserts that the set of all linear combinations of 42 and 105 that is, the set of all numbers of the form 42a + 105b is..., 42, 21, 0, 21,42,63,.... Notice that the greatest common divisor is the smallest positive element of this set. If you know a little group theory, you may recognize this as the result that subgroups of cyclic groups are cyclic. c 2006 by Bruce Ikenaga 4

The Extended Euclidean Algorithm 7-20-2006 The Extended Euclidean Algorithm finds integers a and b such that (m, n) = am + bn. The backward recurrence is an implementation of the Extended Euclidean Algorithm. This implementation is well suited for hand computation. The Euclidean algorithm is an efficient way of computing the greatest common divisor of two numbers. It also provides a way of finding numbers a, b, such that The Euclidean Algorithm. Take m, n > 0. Define (x, y) = ax + by. r 0 = m, r 1 = n. Then recursively define r k using the Division Algorithm: r k 2 = qr k 1 + r k, where 0 r k < r k 1. The inequality 0 r k < r k 1 shows that the r k s form a decreasing sequence of nonnegative integers. It follows that the algorithm must terminate. Example. Compute (1914, 899). 1914 = 2 899 + 116 899 = 7 116 + 87 116 = 1 87 + 29 87 = 3 29 + 0 The greatest common divisor is the last nonzero remainder: (1914, 899) = 29. By an earlier result, the greatest common divisor 29 must be a linear combination a 1914+b 899. Here s how to find integers a and b which work. Simply work backwards through the equations above, treating the r k s as if they were variables. Substituting for 87 in the first equation, 29 = 116 + ( 1) 87 and 87 = 899 + ( 7) 116. 29 = 116 + ( 1) [899 + ( 7) 116] = ( 1) 899 + 8 116. But 116 = 1914 + ( 2) 899. Substituting for 116, I find that 29 = ( 1) 899 + 8 [1914 + ( 2) 899] = 8 1914 + ( 17) 899. I ve written the greatest common divisor 29 as a linear combination of the original numbers 1914 and 899. 1

While you can use this back-substitution approach to write the greatest common divisor as a linear combination of the original numbers, it s rather tedious. Here s a better way. I ll write it more formally, since the steps are a little complicated. Terminology. If a and b are things, a linear combination of a and b is something of the form sa + tb, where s and t are numbers. (The kind of number depends on the context.) I proved the next result earlier, but this proof will actually give an algorithm which constructs a linear combination. It is called a backward recurrence, and appeared in a paper by S. P. Glasby [1]. It will look a little complicated, but you ll see that it s really easy to use in practice. Theorem. (a, b) is a linear combination of a and b: (a, b) = sa + tb for some integers s and t. Warning: s and t are not unique. Proof. (a, b) is only defined if at least one of a, b is nonzero. If a 0, (a, 0) = a and a = 1 a + 0 0. This proves the result if one of the numbers is 0, so I may as well assume both are nonzero. Moreover, since (a, b) = ( a, b ), I can assume both numbers are positive. Suppose a b. Apply the Euclidean Algorithm to a 0 = a and a 1 = b, and suppose that a n is the last nonzero remainder: a 0 = a 1 q 1 + a 2, where 0 a 2 < a 1 a 1 = a 2 q 2 + a 3, where 0 a 3 < a 2. a k = a k+1 q k+1 + a k+2, where 0 a k+2 < a k+1. a n 1 = a n q n + 0. I m going to define a sequence of numbers y n, y n 1,...y 1, y 0. They will be constructed recursively, starting with y n, y n 1 and working downward to y 0. (This is why this is called a backward recurrence.) Define y n = 0 and y n 1 = 1. Then define Now I claim that y k 1 = q k y k + y k+1 for k = n 2,..., 2, 1. ( 1) n+k+1 a k 1 y k + ( 1) n+k a k y k 1 = a n for 1 k n. I will prove this by downward induction, starting with k = n and working downward to k = 1. For k = n, I have ( 1) 2n+1 a n 1 y n + ( 1) 2n a n y n 1 = a n 1 y n + a n y n 1 = a n 1 0 + a n 1 = a n. The result holds for k = n. Next, suppose 1 < k < n. Suppose the result holds for k + 1, i.e. ( 1) n+k+2 a k y k+1 + ( 1) n+k+1 a k+1 y k = a n. I want to prove the result for k. Substitute y k+1 = y k 1 q k y k in the preceding equation and simplify: a n = ( 1) n+k+2 a k y k+1 + ( 1) n+k+1 a k+1 y k = ( 1) n+k+2 a k (y k 1 q k y k ) + ( 1) n+k+1 a k+1 y k = ( 1) n+k a k (y k 1 q k y k ) + ( 1) n+k+1 a k+1 y k = ( 1) n+k a k y k 1 + ( 1) n+k+1 a k q k y k + ( 1) n+k+1 a k+1 y k = ( 1) n+k a k y k 1 + (a k q k + a k+1 )( 1) n+k+1 y k = ( 1) n+k a k y k 1 + ( 1) n+k+1 a k 1 y k. 2

This proves the result for k, so the result holds for 1 k n, by downward induction. In particular, for k = 1, the result says a n = ( 1) n+1 a 1 y 0 + ( 1) n+2 a 0 y 1 = ( 1) n+1 a 1 y 0 + ( 1) n a 0 y 1 = [( 1) n y 1 ] a 0 + [ ( 1) n+1 y 0 ] a1. Since a n = (a 0, a 1 ), I ve expressed (a 0, a 1 ) as a linear combination of a 0 and a 1. There are many algorithms (like the one in the proof) which produce a linear combination. I ll call this algorithm the Extended Euclidean Algorithm. Example. In this example, I ll show how you can use the algorithm in the proof to obtain a linear combination. I ll arrange the computations in the form of a table; the table is simply an extension of the table I used for the Euclidean algorithm. Here s how you start: 187-102 (You can save a step by putting the larger number first.) The a and q columns are filled in using the Euclidean algorith, i.e. by successive division: Divide the next-to-the-last a by the last a. The quotient goes into the q-column, and the remainder goes into the a-column. 187-102 1 85 187-102 1 85 1 Divide 187 by 102; Quotient 1, remainder 85. 17 Divide 102 by 85; Quotient 1, remainder 17. When the division comes out evenly, you stop. In this case, 85 divided by 17 is 5, with remainder 0. 187-102 1 85 1 17 5 3

The last entry in the a-column is the greatest common divisor. Thus, (187, 102) = 17. The y-column is filled in from bottom to top. Always start with 0 for the last y and 1 for the next-tothe-last y. 187-102 1 85 1 1 17 5 0 Then, working from bottom to top, fill in the y s using the rule It s probably easier to show than it is to explain: (next y) = (last q) (last y) + (next-to-last y). 187-102 1 1 85 1 1 17 5 0 187-2 102 1 1 85 1 1 17 5 0 1 1 + 0 = 1 1 1 + 1 = 2 To get the linear combination, form the products diagonally and subtract one from the other: 187-2 102 1 1 85 1 1 17 5 0 Thus, 17 = (187, 102) = (2)(102) (1)(187). How do you know the order for the subtraction? The proof gives a formula, but the easiest thing is to pick one of the two ways, then fix it if it isn t right. If you subtract the wrong way, you ll get a negative number. For example, (1)(187) (2)(102) = 17. Since I know the greatest common divisor should be 17 it s the last number in the a-column I just multiply this equation by 1: ( 1)(187) + (2)(102) = 17. 4

This way, you don t need to memorize the exact formula. Example. Compute (246, 194) and express it as a linear combination of 246 and 194. 246-52 194 1 41 52 3 11 38 1 8 14 2 3 10 1 2 4 2 1 2 2 0 Thus, 2 = (246, 194) = 52 194 41 246. I think this algorithm is the best for hand computation. For implementation on a computer, it has a drawback: You need to store all the Euclidean algorithm quotients and remainders, because you need to work your way backward up the table. There is another version of this algorithm which only requires that you save a couple of table lines at a time; it is not as good for hand computation, since you need two helper variables x and y at each step. [1] S. P. Glasby, Extended Euclid s algorithm via backward recurrence relations, Mathematics Magazine, 72(3)(1999), 228 230. c 2006 by Bruce Ikenaga 5