Notes for Recitation 6

Similar documents
The following is an informal description of Euclid s algorithm for finding the greatest common divisor of a pair of numbers:

NOTES ON SIMPLE NUMBER THEORY

The Euclidean Algorithm

5: The Integers (An introduction to Number Theory)

Chapter 5: The Integers

(e) Commutativity: a b = b a. (f) Distributivity of times over plus: a (b + c) = a b + a c and (b + c) a = b a + c a.

2 Arithmetic. 2.1 Greatest common divisors. This chapter is about properties of the integers Z = {..., 2, 1, 0, 1, 2,...}.

2. THE EUCLIDEAN ALGORITHM More ring essentials

Chapter 5. Number Theory. 5.1 Base b representations

Applied Cryptography and Computer Security CSE 664 Spring 2017

Intermediate Math Circles February 26, 2014 Diophantine Equations I

2 Elementary number theory

Math Circle Beginners Group February 28, 2016 Euclid and Prime Numbers Solutions

Introduction to Number Theory. The study of the integers

Induction. Induction. Induction. Induction. Induction. Induction 2/22/2018

Greatest Common Divisor MATH Greatest Common Divisor. Benjamin V.C. Collins, James A. Swenson MATH 2730

Ch 4.2 Divisibility Properties

4 Powers of an Element; Cyclic Groups

Chapter 5.1: Induction

COMP239: Mathematics for Computer Science II. Prof. Chadi Assi EV7.635

NOTES ON INTEGERS. 1. Integers

a the relation arb is defined if and only if = 2 k, k

Homework 3, solutions

Math Circles - Lesson 2 Linear Diophantine Equations cont.

Remainders. We learned how to multiply and divide in elementary

Elementary Algebra Chinese Remainder Theorem Euclidean Algorithm

REAL NUMBERS. Any positive integer a can be divided by another positive integer b in such a way that it leaves a remainder r that is smaller than b.

Math Circle Beginners Group February 28, 2016 Euclid and Prime Numbers

a = qb + r where 0 r < b. Proof. We first prove this result under the additional assumption that b > 0 is a natural number. Let

Mat Week 8. Week 8. gcd() Mat Bases. Integers & Computers. Linear Combos. Week 8. Induction Proofs. Fall 2013

Student Responsibilities Week 8. Mat Section 3.6 Integers and Algorithms. Algorithm to Find gcd()

The Euclidean Algorithm and Multiplicative Inverses

CMPUT 403: Number Theory

An Algorithm for Prime Factorization

Exercises Exercises. 2. Determine whether each of these integers is prime. a) 21. b) 29. c) 71. d) 97. e) 111. f) 143. a) 19. b) 27. c) 93.

Mathematics for Computer Science Exercises for Week 10

Lecture Notes. Advanced Discrete Structures COT S

EUCLID S ALGORITHM AND THE FUNDAMENTAL THEOREM OF ARITHMETIC after N. Vasiliev and V. Gutenmacher (Kvant, 1972)

Wednesday, February 21. Today we will begin Course Notes Chapter 5 (Number Theory).

An integer p is prime if p > 1 and p has exactly two positive divisors, 1 and p.

The Fundamental Theorem of Arithmetic

CHAPTER 6. Prime Numbers. Definition and Fundamental Results

CSE 311: Foundations of Computing. Lecture 12: Two s Complement, Primes, GCD

Intermediate Math Circles February 29, 2012 Linear Diophantine Equations I

MATH FINAL EXAM REVIEW HINTS

1 Overview and revision

Writing Assignment 2 Student Sample Questions

Homework #2 Solutions Due: September 5, for all n N n 3 = n2 (n + 1) 2 4

MATH 501 Discrete Mathematics. Lecture 6: Number theory. German University Cairo, Department of Media Engineering and Technology.

CS250: Discrete Math for Computer Science

8 Primes and Modular Arithmetic

Senior Math Circles Cryptography and Number Theory Week 2

The next sequence of lectures in on the topic of Arithmetic Algorithms. We shall build up to an understanding of the RSA public-key cryptosystem.

4. Number Theory (Part 2)

Solutions to Assignment 1

Lecture 4: Number theory

Algorithmic number theory. Questions/Complaints About Homework? The division algorithm. Division

CS 5319 Advanced Discrete Structure. Lecture 9: Introduction to Number Theory II

Notes on Systems of Linear Congruences

then the hard copy will not be correct whenever your instructor modifies the assignments.

2.2 Inverses and GCDs

Elementary Properties of the Integers

Direct Proof MAT231. Fall Transition to Higher Mathematics. MAT231 (Transition to Higher Math) Direct Proof Fall / 24

Ma/CS 6a Class 2: Congruences

Number Theory Basics Z = {..., 2, 1, 0, 1, 2,...} For, b Z, we say that divides b if z = b for some. Notation: b Fact: for all, b, c Z:

Lecture Notes Math 371: Algebra (Fall 2006) by Nathanael Leedom Ackerman

7.2 Applications of Euler s and Fermat s Theorem.

2301 Assignment 1 Due Friday 19th March, 2 pm

CHAPTER 3. Congruences. Congruence: definitions and properties

All variables a, b, n, etc are integers unless otherwise stated. Each part of a problem is worth 5 points.

cse 311: foundations of computing Spring 2015 Lecture 12: Primes, GCD, applications

Modular Arithmetic and Elementary Algebra

Modular Arithmetic Instructor: Marizza Bailey Name:

Chapter 3: The Euclidean Algorithm and Diophantine. Math 138 Burger California State University, Fresno

CSC B36 Additional Notes sample induction and well-ordering proofs. c Nick Cheng

PUTNAM TRAINING NUMBER THEORY. Exercises 1. Show that the sum of two consecutive primes is never twice a prime.

(Rgs) Rings Math 683L (Summer 2003)

Chapter 1. Greatest common divisor. 1.1 The division theorem. In the beginning, there are the natural numbers 0, 1, 2, 3, 4,...,

3 The fundamentals: Algorithms, the integers, and matrices

Discrete Mathematics and Probability Theory Fall 2018 Alistair Sinclair and Yun Song Note 6

Chapter 2. Divisibility. 2.1 Common Divisors

INTEGERS. In this section we aim to show the following: Goal. Every natural number can be written uniquely as a product of primes.

Basic elements of number theory

Basic elements of number theory

Discrete Mathematics and Probability Theory Summer 2014 James Cook Note 5

1 Continued Fractions

Divisibility. Def: a divides b (denoted a b) if there exists an integer x such that b = ax. If a divides b we say that a is a divisor of b.

CSE 20 DISCRETE MATH. Winter

Solutions Math 308 Homework 9 11/20/2018. Throughout, let a, b, and c be non-zero integers.

MAT246H1S - Concepts In Abstract Mathematics. Solutions to Term Test 1 - February 1, 2018

MAS114: Solutions to Exercises

18 Divisibility. and 0 r < d. Lemma Let n,d Z with d 0. If n = qd+r = q d+r with 0 r,r < d, then q = q and r = r.

Chapter 1 A Survey of Divisibility 14

PRACTICE PROBLEMS: SET 1

MATH10040 Chapter 1: Integers and divisibility

PROBLEMS ON CONGRUENCES AND DIVISIBILITY

Deepening Mathematics Instruction for Secondary Teachers: Algebraic Structures

6.042/18.062J Mathematics for Computer Science March 9, 2005 Srini Devadas and Eric Lehman. Quiz 1. Ishan Christos Grant

MATH 145 Algebra, Solutions to Assignment 4

8. Given a rational number r, prove that there exist coprime integers p and q, with q 0, so that r = p q. . For all n N, f n = an b n 2

Transcription:

6.042/18.062J Mathematics for Computer Science February 18, 2005 Srini Devadas and Eric Lehman Notes for Recitation 6 1 The Pulverizer We saw in lecture that the greatest common divisor (GCD) of two numbers can be written as a linear combination of them. 1 That is, no matter which pair of integers a and b we are given, there is always a pair of integer coefficients s and t such that gcd(a, b) = sa + tb. However, the proof was nonconstructive: it didn t suggest a way for finding such s and t. That job is tackled by a mathematical tool that dates to sixth century India, where it was called kuttak, which means The Pulverizer. Today, the Pulverizer is more commonly known as the extended Euclidean GCD algorithm, but that s lame. We re sticking with Pulverizer. Euclid s algorithm for finding the GCD of two numbers relies on repeated application of the equation: gcd(a, b) = gcd(b, a rem b) which was proved in lecture (see the notes Number Theory I ). For example, we can compute the GCD of 259 and 70 as follows: gcd(259, 70) = gcd(70, 49) since 259 rem 70 = 49 = gcd(49, 21) since 70 rem 49 = 21 = gcd(21, 7) since 49 rem 21 = 7 = gcd(7, 0) since 21 rem 7 = 0 = 7. The Pulverizer goes through the same steps, but requires some extra bookkeeping along the way: as we compute gcd(a, b), we keep track of how to write each of the remainders (49, 21, and 7, in the example) as a linear combination of a and b (this is worthwhile, because our objective is to write the last nonzero remainder, which is the GCD, as such a 1 In fact, we proved that among all positive linear combinations of the numbers their GCD is the smallest.

Recitation 6 2 linear combination). For our example, here is this extra bookkeeping: x y (x rem y) = x q y 259 70 49 = 259 3 70 70 49 21 = 70 1 49 = 70 1 (259 3 70) = 1 259 + 4 70 49 21 7 = 49 2 21 = (259 3 70) 2 ( 1 259 + 4 70) 21 7 0 = 3 259 11 70 We began by initializing two variables, x = a and y = b. In the first two columns above, we carried out Euclid s algorithm. At each step, we computed x rem y, which can be written in the form x q y. (Remember that the Division Algorithm says x = q y + r, where r is the remainder. We get r = x q y by rearranging terms.) Then we replaced x and y in this equation with equivalent linear combinations of a and b, which we already had computed. After simplifying, we were left with a linear combination of a and b that was equal to the remainder as desired. The final solution is boxed.

Recitation 6 3 2 Problem: The Pulverizer! There is a pond. Inside the pond there are n pebbles, arranged in a cycle. A frog is sitting on one of the pebbles. Whenever he jumps, he lands exactly k pebbles away in the clockwise direction, where 0 < k < n. The frog s meal, a delicious worm, lies on the pebble right next to his, in the clockwise direction. (a) Describe a situation where the frog can t reach the worm. Solution. If k n (say k = 3 and n = 6), then no number of jumps will lead the frog to the worm, as the frog will be returning to his original pebble ad infinitum. (b) In a situation where the frog can actually reach the worm, explain how to use the Pulverizer to find how many jumps the frog will need. Solution. Suppose the frog can reach the worm. When he actually reaches it, he has jumped a number of times, say j, and he has travelled around the cycle a number of times, call it c. Then, the distance that the frog has covered is both j k and c n + 1, so that jk = cn + 1. But this means that 1 can be written as a linear combination of n and k: ( c)n + jk = 1. Since 1 is positive, we conclude that it is a positive linear combination of n and k. And since it is the smallest positive integer, we also conclude that it is the smallest positive linear combination of n and k. But we have proved in lecture that the smallest positive linear combination of two integers is their GCD. So, the GCD of n and k is 1: gcd(n, k) = 1 and we can use the Pulverizer to find c and j. (c) Compute the number of jumps if n = 50 and k = 21. Anything strange? Solution. We go through the steps as described in Section 1 (see the table below) to get that 1 = 8 50 19 21, or 1 = ( 8) 50 + ( 19) 21. Hence, c = 8 and j = 19, which makes little sense. What does it mean for the frog to make 19 jumps? The point is that the Pulverizer is guaranteed to give us the integers coefficients of a linear combination that equals the GCD, but it promises nothing about the signs of those coefficients which, in this case we wanted them to be and +. To get coefficients of the desired sign, we have to think more (and much less after the next lecture). So, we know 1 = 8 50 19 21. Or, to obtain meaningful signs for the numbers, 19 21 = 8 50 1. That is, after 19 jumps the frog will have covered 8 full cycles but 1 pebble. So, he will be right next to his original pebble, but in the counter clockwise direction. Given this, how can he reach the pebble he is after?

Recitation 6 4 Well, if he makes 19 more jumps, he will land 2 pebbles away from his original position in the counter clockwise direction. Another 19 jumps will lead him 3 pebbles away, and so on. After a total of 49 sets of 19 jumps, he will be 49 pebbles away from its original position in the counter clockwise direction, which is of course the worm s pebble. Then, the frog will have made 49 19 = 931 jumps. Here is the table produced by the Pulverizer: x y (x rem y) = x q y 50 21 8 = 50 2 21 21 8 5 = 21 2 8 = 21 2 (50 2 21) = 2 50 + 5 21 8 5 3 = 8 1 5 = (50 2 21) 1 ( 2 50 + 5 21) = 3 50 7 21 5 3 2 = 5 1 3 = ( 2 50 + 5 21) 1 (3 50 7 21) = 5 50 + 12 21 3 2 1 = 3 1 2 = (3 50 7 21) 1 ( 5 50 + 12 21) 2 1 0 = 8 50 19 21

Recitation 6 5 3 Problem: The Fibonacci numbers. Again. Give an inductive proof that the Fibonacci numbers F n and F n+1 are relatively prime for all n 0. Recall that the Fibonacci numbers are defined as follows: F 0 = 0 F 1 = 1 F n = F n 1 + F n 2 (for n 2). Solution. We use induction on n. Let P (n) be the proposition that F n and F n+1 are relatively prime. Base case: P (0) is true because F 0 = 0 and F 1 = 1 are relatively prime. Inductive step: We show that, for all n 0, P (n) implies P (n + 1). So, fix some n 0 and assume that P (n) is true, that is, F n and F n+1 are relatively prime. We will show that F n+1 and F n+2 are relatively prime as well. We will do this by contradiction. Suppose F n+1 and F n+2 are not relatively prime. Then they have a common divisor d > 1. But then d also divides the linear combination F n+2 F n+1, which actually equals F n. Hence, d > 1 divides both F n and F n+1. Which implies F n, F n+1 are not relatively prime, a contradiction to the inductive hypothesis. Therefore, F n+1 and F n+2 are relatively prime. That is, P (n + 1) is true. The theorem follows by induction.

Recitation 6 6 4 Problem: The power of 3. Let N be a number whose decimal expansion consists of 3 n identical digits. Show by induction that 3 n N. For example: 3 2 } 777777777 {{} 3 2 = 9 digits Recall that 3 divides a number iff it divides the sum of its digits. Solution. We proceed by induction on n. Let P (n) be the proposition that 3 n N, where the decimal expansion of N consists of 3 n identical digits. Base case. P (0) is true because 3 0 = 1 divides every number. Inductive step. Now we show that, for all n 0, P (n) implies P (n + 1). Fix any n 0 and assume P (n) is true. Consider a number whose decimal expansion consists of 3 n+1 copies of the digit a: aaaaaa... aaaaaa = aaa... aaa aaa... aaa aaa... aaa }{{}}{{}}{{}}{{} 3 n+1 digits 3 n digits 3 n digits 3 n digits = aaa }.{{.. aaa } 1 000 }.{{.. 001} 000 }.{{.. 001 } 3 n digits 3 n digits 3 n digits Now 3 n divides the first term by the assumption P (n), and 3 divides the second term since the digits sum to 3. Therefore, the whole expression is divisible by 3 n+1. This proves P (n + 1). By the principle of induction P (n) is true for all n 0.