2. Integers and Algorithms Euclidean Algorithm. Euclidean Algorithm. Suppose a and b are integers

Similar documents
8 Divisibility and prime numbers

Section 4.2: The Division Algorithm and Greatest Common Divisors

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

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

CS 103X: Discrete Structures Homework Assignment 3 Solutions

GREATEST COMMON DIVISOR

Today s Topics. Primes & Greatest Common Divisors

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

Homework until Test #2

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

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

MATH10040 Chapter 2: Prime and relatively prime numbers

Continued Fractions and the Euclidean Algorithm

Intermediate Math Circles March 7, 2012 Linear Diophantine Equations II

Handout NUMBER THEORY

8 Primes and Modular Arithmetic

MATH 289 PROBLEM SET 4: NUMBER THEORY

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

Elementary Number Theory

Discrete Mathematics, Chapter 4: Number Theory and Cryptography

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

The Euclidean Algorithm

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

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

I. GROUPS: BASIC DEFINITIONS AND EXAMPLES

Lecture 3: Finding integer solutions to systems of linear equations

11 Ideals Revisiting Z

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

Page 331, 38.4 Suppose a is a positive integer and p is a prime. Prove that p a if and only if the prime factorization of a contains p.

SUM OF TWO SQUARES JAHNAVI BHASKAR

3. Mathematical Induction

Basic Proof Techniques

z 0 and y even had the form

Number Theory: A Mathemythical Approach. Student Resources. Printed Version

Applications of Fermat s Little Theorem and Congruences

17 Greatest Common Factors and Least Common Multiples

DIVISIBILITY AND GREATEST COMMON DIVISORS

Quotient Rings and Field Extensions

Test1. Due Friday, March 13, 2015.

Breaking The Code. Ryan Lowe. Ryan Lowe is currently a Ball State senior with a double major in Computer Science and Mathematics and

k, then n = p2α 1 1 pα k

MATHEMATICAL INDUCTION. Mathematical Induction. This is a powerful method to prove properties of positive integers.

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

6.2 Permutations continued

Handout #1: Mathematical Reasoning

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

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

Winter Camp 2011 Polynomials Alexander Remorov. Polynomials. Alexander Remorov

SYSTEMS OF PYTHAGOREAN TRIPLES. Acknowledgements. I would like to thank Professor Laura Schueller for advising and guiding me

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

On the generation of elliptic curves with 16 rational torsion points by Pythagorean triples

Unique Factorization

COMP 250 Fall 2012 lecture 2 binary representations Sept. 11, 2012

RSA and Primality Testing

PYTHAGOREAN TRIPLES KEITH CONRAD

26 Integers: Multiplication, Division, and Order

Math 319 Problem Set #3 Solution 21 February 2002

MATH 537 (Number Theory) FALL 2016 TENTATIVE SYLLABUS

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

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

Factoring & Primality

Continued Fractions. Darren C. Collins

FACTORING POLYNOMIALS IN THE RING OF FORMAL POWER SERIES OVER Z

Mathematical Induction

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.

ABSTRACT ALGEBRA: A STUDY GUIDE FOR BEGINNERS

We can express this in decimal notation (in contrast to the underline notation we have been using) as follows: b + 90c = c + 10b

PRIME FACTORS OF CONSECUTIVE INTEGERS

POLYNOMIAL RINGS AND UNIQUE FACTORIZATION DOMAINS

15 Prime and Composite Numbers

Systems of Linear Equations

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

An Introductory Course in Elementary Number Theory. Wissam Raji

The Fundamental Theorem of Arithmetic

Settling a Question about Pythagorean Triples

V Quantitative Reasoning: Computers, Number Theory and Cryptography

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

Fibonacci Numbers and Greatest Common Divisors. The Finonacci numbers are the numbers in the sequence 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144,...

CONTENTS 1. Peter Kahn. Spring 2007

SOLUTIONS FOR PROBLEM SET 2

Lectures on Number Theory. Lars-Åke Lindahl

minimal polyonomial Example

PROBLEM SET 6: POLYNOMIALS

Gröbner Bases and their Applications

ALGEBRAIC APPROACH TO COMPOSITE INTEGER FACTORIZATION

SECTION 10-2 Mathematical Induction

Solutions of Linear Equations in One Variable

Public Key Cryptography: RSA and Lots of Number Theory

The Division Algorithm for Polynomials Handout Monday March 5, 2012

Chapter 11 Number Theory

of Nebraska - Lincoln

Every Positive Integer is the Sum of Four Squares! (and other exciting problems)

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

Properties of Real Numbers

STUDENT S SOLUTIONS MANUAL ELEMENTARY NUMBER THEORY. Bart Goddard. Kenneth H. Rosen AND ITS APPLICATIONS FIFTH EDITION. to accompany.

LS.6 Solution Matrices

The Chinese Remainder Theorem

mod 10 = mod 10 = 49 mod 10 = 9.

CS 173, Spring 2015 Examlet 2, Part A

4.2 Euclid s Classification of Pythagorean Triples

Transcription:

2. INTEGERS AND ALGORITHMS 155 2. Integers and Algorithms 2.1. Euclidean Algorithm. Euclidean Algorithm. Suppose a and b are integers with a b > 0. (1) Apply the division algorithm: a = bq + r, 0 r < b. (2) Rename b as a and r as b and repeat until r = 0. The last nonzero remainder is the greatest common divisor of a and b. The Euclidean Algorithm depends upon the following lemma. Lemma 2.1.1. If a = bq + r, then GCD(a, b) = GCD(b, r). Proof. We will show that if a = bq + r, then an integer d is a common divisor of a and b if, and only if, d is a common divisor of b and r. Let d be a common divisor of a and b. Then d a and d b. Thus d (a bq), which means d r, since r = a bq. Thus d is a common divisor of b and r. Now suppose d is a common divisor of b and r. Then d b and d r. Thus d (bq + r), so d a. Therefore, d must be a common divisor of a and b. Thus, the set of common divisors of a and b are the same as the set of common divisors of b and r. It follows that d is the greatest common divisor of a and b if and only if d is the greatest common divisor of b and r. Discussion The fact that the Euclidean algorithm actually gives the greatest common divisor of two integers follows from the division algorithm and the equality in Lemma 2.1.1. Applying the division algorithm repeatedly as indicated yields a sequence of remainders r 1 > r 2 > > r n > 0 = r n+1, where r 1 < b. Lemma 2.1.1 says that GCD(a, b) = GCD(b, r 1 ) = GCD(r 1, r 2 ) = = GCD(r n 1, r n ). But, since r n+1 = 0, r n divides r n 1, so that GCD(r n 1, r n ) = r n. Thus, the last nonzero remainder is the greatest common divisor of a and b. Example 2.1.1. Find GCD (1317, 56).

2. INTEGERS AND ALGORITHMS 156 1317 = 56(23) + 29 56 = 29(1) + 27 29 = 27(1) + 2 27 = 2(13) + 1 2 = 1(2) + 0 GCD (1317,56)=1 Example 2.1.1 shows how to apply the Euclidean algorithm. Notice that when you proceed from one step to the next you make the new dividend the old divisor (replace a with b) and the new divisor becomes the old remainder (replace b with r). Recall that you can find the quotient q by dividing b into a on your calculator and rounding down to the nearest integer. (That is, q = a/b.) You can then solve for r. Alternatively, if your calculator has a mod operation, then r = mod(a, b) and q = (a r)/b. Since you only need to know the remainders to find the greatest common divisor, you can proceed to find them recursively as follows: Basis. r 1 = a mod b, r 2 = b mod r 1. Recursion. r k+1 = r k 1 mod r k, for k 2. (Continue until r n+1 = 0 for some n. ) 2.2. GCD s and Linear Combinations. Theorem 2.2.1. If d = GCD(a, b), then there are integers s and t such that d = as + bt. Moreover, d is the smallest positive integer that can be expressed this way. Discussion Theorem 2.2.1 gives one of the most useful characterizations of the greatest common divisor of two integers. Given integers a and b, the expression as + bt, where s and t are also integers, is called a linear combination of a and b. Exercise 2.2.1. Prove that if a, b, s, t, and d are integers such that d a and d b, then d (as + bt). The Euclidean Algorithm can, in fact, be used to provide the representation of the greatest common divisor of a and b as a linear combination of a and b. Here is how it would work for the example in Example 2.1.1.

2. INTEGERS AND ALGORITHMS 157 Example 2.2.1. Express 1 = GCD(1317, 56) as a linear combination of 1317 and 56. Solution: We work backwards using the equations derived by applying the Euclidean algorithm in example 2.1.1, expressing each remainder as a linear combination of the associated divisor and dividend: 1 = 27 13 2 linear combination of 2 and 27 1 = 27 13(29 27 1) substitute 2 = 29 27(1) 1 = 14 27 13 29 linear combination of 27 and 29 1 = 14(56 1 29) 13 29 substitute 27 = 56 1 29 1 = 14 56 27 29 linear combination of 29 and 56 1 = 14 56 27(1317 23 56) substitute 29 = 1317 23 56 1 = 635 56 27 1317 linear combination of 56 and 1317 (The dividends, divisors, and remainders have been underlined.) So GCD(1317, 56) = 1 = 1317( 27) + 56(635). Theorem 2.2.1 can be proved by mathematical induction following the idea in the preceding example. Proof of Theorem 2.2.1. Suppose a and b are integers. We may assume a and b are positive, since GCD(a, b) = GCD(±a, ±b). The Euclidean algorithm uses the division algorithm to produce a sequence of quotients and remainders as follows: r n 2 a = bq 1 + r 1 b = r 1 q 2 + r 2 r 1 = r 2 q 3 + r 3. = r n 1 q n + r n r n 1 = r n q n+1 + 0 where r n is the last nonzero remainder. We will use the second principle of mathematical induction to prove that r k is a linear combination of a and b for 1 k n. 1. Basis Step (k = 1). r 1 = a bq 1 = a(1) + b( q 1 ). 2. Induction Step. Suppose r i is a linear combination of a and b for 1 i k. For 1 k n we have r k+1 = r k 1 r k q k+1

2. INTEGERS AND ALGORITHMS 158 (where r 0 = b when k = 1). By the inductive hypothesis r k 1 and r k are linear combinations of a and b. (This works for k = 1, since r 0 = b is trivially a linear combination of a and b.) Write and r k 1 = as 1 + bt 1 r k = as 2 + bt 2 for integers s 1, t 1, s 2, t 2, and substitute into the equation above: r k+1 = (as 1 + bt 1 ) (as 2 + bt 2 )q k+1 = a(s 1 s 2 q k+1 ) + b(t 1 t 2 q k+1 ). Thus, r k+1 is a linear combination of a and b. By the second principle of mathematical induction, r n is a linear combination of a and b. But r n is the greatest common divisor of a and b. This proves the first part of the theorem. Next, we show that d is the smallest positive integer expressible as a linear combination of a and b. Suppose a positive integer c can be expressed as a linear combination of a and b: c = ax + by for integers x and y. Since d a and d b, then d c, which implies d c. Here is an alternative proof of Theorem 2.2.1 that does not use the Euclidean algorithm. Second proof of Theorem 2.2.1. Let S be the set of all positive integers that can be expressed as a linear combination of the positive integers a and b. Clearly S, since a, b S. By the well-ordering principle S has a least element d. We will prove by contradiction that d a and d b. If d a, then use the division algorithm to get integers q and r such that a = dq + r, where 0 < r < d. Since both a and d are linear combinations of a and b, then r = a dq is also. But this means that r S, contradicting the fact that d is the smallest member of S. Similarly, one shows that d b. If c is a divisor of a and b, then c divides any linear combination of a and b; hence, c d. Thus, d = GCD(a, b). Exercise 2.2.2. Prove that if p is a prime number and n is an integer that is not divisible by p, then there are integers s and t such that ps + nt = 1. [First show that GCD(p, n) = 1.]

2. INTEGERS AND ALGORITHMS 159 1. Exercise 2.2.3. Prove that if 1 is a linear combination of a and b, then GCD(a, b) = 2.3. Uniqueness of Prime Factorization. Lemma 2.3.1. If GCD(a, b) = 1 and a bc, then a c. Proof. Assume GCD(a, b) = 1 and a bc. Write 1 = as + bt for integers s and t. Multiply both sides by c: c = acs + bct. Since a bc, a divides this linear combination of a and bc. a(cs) + (bc)t = c Theorem 2.3.1. Suppose a and b are integers and p is a prime number. If p ab, then p a or p b. Proof. We will prove the equivalent statement: if p ab and p a, then p b. (You should convince yourself that the two propositional forms P (Q R) and (P Q) R are equivalent.) Suppose p ab and p a. Then GCD(p, a) = 1. By the Lemma 1, p b. Discussion Theorem 2.3.1 is very useful in deciding how prime factors are distributed in a product of two integers. For example, we gave an indirect proof in Module 3.2 that if the product of two integers x and y is even, then either x is even or y is even. As we hinted there, a direct proof is possible, and Theorem 2.3.1 provides just the right information to make it work. Exercise 2.3.1. Use Theorem 2.3.1 to give a direct proof that if the product of two integers x and y is even, then either x is even or y is even. Exercise 2.3.2. Use mathematical induction to prove the following generalization of Theorem 2.3.1. Suppose a 1, a 2,..., a n are integers and p is a prime number. If p a 1 a 2 a n, then p a i for some i = 1, 2,..., n. [Hint: The induction step has two cases.] Exercise 2.3.3. Use Lemma 2.3.1 to prove that if k, l, and m are positive integers such that k m, l m, and k and l are relatively prime, then the product kl m.

2. INTEGERS AND ALGORITHMS 160 Exercise 2.3.4. Suppose a and b are positive integers, d = GCD(a, b), a = dk, and b = dl. Prove that k and l are relatively prime. [Hint: Show that 1 can be expressed as a linear combination of k and l.] We can now give a proof of Theorem 6 of Module 5.1 Integers and Division: If a and b are positive integers, then ab = GCD(a, b) LCM(a, b). Proof of Theorem 6, Module 5.1. Let d = GCD(a, b). Write a = dk, b = dl, where k and l are positive integers, which, by Exercise 2.3.4, are relatively prime. Then ab = (dk)(dl) = d (kld) = GCD(a, b) (kld). We will succeed once we show that kld = LCM(a, b). We will prove this by contradiction. Suppose m = LCM(a, b) and m < kld. Observe that kld = (dk)l = al and kld = (dl)k = bk. That is, both a and b divide kld; hence, their least common multiple m does also. Since k a and l b, k and l both divide m; hence, by Exercise 2.3.3, the product kl m. [Aside: We also know that d divides m, so it is tempting to assert that kld also divides m. But we can t use Exercise 2.3.3 to conclude this, since d may not be relatively prime to either k or l. Can you give an example where d divides both k and l?] Thus m = klx for some positive integer x, and x < d, by hypothesis. Since m kld, x d. Write d = xy, where y is an integer > 1. Now: a = dk = xyk m = klx, so y l. b = dl = xyl m = klx, so y k. This implies that k and l are not relatively prime, since y > 1. Thus, the assumption m < kld is false, and so m = kld. This generalization of Theorem 2.3.1 can be used to prove the uniqueness of prime factorizations asserted in the Fundamental Theorem of Arithmetic (Module 5.1): If n is a positive integer greater than 1, then n can be written uniquely as a product of prime numbers where the factors appear in nondecreasing order.

2. INTEGERS AND ALGORITHMS 161 Proof of uniqueness of prime factorization. We have already shown that we can write any integer n > 1 as a product n = p 1 p 2 p k, where each p i is prime. By reordering the factors, if necessary, we can always assume that p 1 p 2 p k. We will prove by induction on k that if an integer n > 1 has a factorization into k primes, k 1, then the factorization is unique. 1. Basis Step (k = 1). In this case n = p 1 is prime, and so it has no other factorization into primes. 2. Induction Step. Assume that every integer that can be factored into k primes has a unique factorization. Suppose where each p i is prime and n = p 1 p 2 p k p k+1, p 1 p 2 p k p k+1. Suppose n has another prime factorization n = q 1 q 2 q l, where each q j is prime (possibly, l k + 1) and q 1 q 2 q l. By the generalization of Theorem 2.3.1 in Exercise 2.3.2, since p 1 n = q 1 q 2 q l, then p 1 q j for some j. But q j is also prime, so p 1 = q j q 1. On the other hand, since q 1 p 1 p 2 p k p k+1, then q 1 p i for some i, and since p i is prime, q 1 = p i p 1. But if p 1 q 1 and q 1 p 1, then p 1 = q 1. Thus we can cancel the first factor from both sides of the equation to get p 1 p 2 p k p k+1 = q 1 q 2 q l p 2 p k p k+1 = q 2 q l. The integer on the left-hand side of this equation has a prime factorization using k primes. By the induction hypothesis, this factorization is unique. This means that l = k + 1 and p 2 = q 2, p 3 = q 3,..., p k+1 = q k+1. Thus, p i = q i for 1 i k + 1, and the factorization of n is unique.

2. INTEGERS AND ALGORITHMS 162 By the first principle of mathematical induction, every integer greater than one has a unique prime factorization.