Mathematics for Computer Science Exercises for Week 10

Similar documents
Ch 4.2 Divisibility Properties

Proofs. Methods of Proof Divisibility Floor and Ceiling Contradiction & Contrapositive Euclidean Algorithm. Reading (Epp s textbook)

Senior Math Circles Cryptography and Number Theory Week 2

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.

Homework #2 solutions Due: June 15, 2012

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

PRACTICE PROBLEMS: SET 1

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

5: The Integers (An introduction to Number Theory)

Discrete Math in Computer Science Solutions to Practice Problems for Midterm 2

2 Elementary number theory

Number Theory and Graph Theory. Prime numbers and congruences.

MATH 55 - HOMEWORK 6 SOLUTIONS. 1. Section = 1 = (n + 1) 3 = 2. + (n + 1) 3. + (n + 1) 3 = n2 (n + 1) 2.

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

Fall 2015 Lecture 14: Modular congruences. cse 311: foundations of computing

Introduction to Number Theory

Chapter 5. Number Theory. 5.1 Base b representations

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

Number Theory Proof Portfolio

Intermediate Math Circles February 29, 2012 Linear Diophantine Equations I

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

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:

ALGEBRA. 1. Some elementary number theory 1.1. Primes and divisibility. We denote the collection of integers

Proof 1: Using only ch. 6 results. Since gcd(a, b) = 1, we have

MATH FINAL EXAM REVIEW HINTS

Arithmetic Algorithms, Part 1

1 Overview and revision

NOTES ON INTEGERS. 1. Integers

12x + 18y = 50. 2x + v = 12. (x, v) = (6 + k, 2k), k Z.

Discrete Structures Lecture Primes and Greatest Common Divisor

Chapter 5: The Integers

Writing Assignment 2 Student Sample Questions

4 Powers of an Element; Cyclic Groups

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

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

Elementary Properties of the Integers

Chapter 5.1: Induction

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

CISC-102 Fall 2017 Week 6

Chapter 2. Divisibility. 2.1 Common Divisors

Number Theory Marathon. Mario Ynocente Castro, National University of Engineering, Peru

Intermediate Math Circles February 26, 2014 Diophantine Equations I

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

#26: Number Theory, Part I: Divisibility

MATH 215 Final. M4. For all a, b in Z, a b = b a.

The set of integers will be denoted by Z = {, -3, -2, -1, 0, 1, 2, 3, 4, }

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

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.

NOTES ON SIMPLE NUMBER THEORY

The Euclidean Algorithm and Multiplicative Inverses

1. multiplication is commutative and associative;

University of Ottawa CSI 2101 Midterm Test Instructor: Lucia Moura. February 9, :30 pm Duration: 1:50 hs. Closed book, no calculators

(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.

MATH 2200 Final Review

3. pour from one decanter to the other until either the receiving decanter is full or the poured decanter is empty.

Number Theory and Group Theoryfor Public-Key Cryptography

Olympiad Number Theory Through Challenging Problems

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

Integers and Division

CSE 311 Lecture 13: Primes and GCD. Emina Torlak and Kevin Zatloukal

Algorithms (II) Yu Yu. Shanghai Jiaotong University

Number Theory and Divisibility

UNIVERSITY OF VICTORIA DECEMBER EXAMINATIONS MATH 122: Logic and Foundations

Basic elements of number theory

Basic elements of number theory

3. pour from one decanter to the other until either the receiving decanter is full or the poured decanter is empty.

Final Exam Review. 2. Let A = {, { }}. What is the cardinality of A? Is

8 Primes and Modular Arithmetic

Number Theory Marathon. Mario Ynocente Castro, National University of Engineering, Peru

1. Factorization Divisibility in Z.

Direct Proof Divisibility

11 Division Mod n, Linear Integer Equations, Random Numbers, The Fundamental Theorem of Arithmetic

Homework 3, solutions

MATHEMATICAL INDUCTION

Direct Proof Divisibility

Applied Cryptography and Computer Security CSE 664 Spring 2017

WORKSHEET ON NUMBERS, MATH 215 FALL. We start our study of numbers with the integers: N = {1, 2, 3,...}

Notes for Recitation 6

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

2. THE EUCLIDEAN ALGORITHM More ring essentials

Cool Results on Primes

C-N Math 207 Discrete Math

C-N Math 207 Discrete Math

WORKSHEET MATH 215, FALL 15, WHYTE. We begin our course with the natural numbers:

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

1. Consider the conditional E = p q r. Use de Morgan s laws to write simplified versions of the following : The negation of E : 5 points

2x 1 7. A linear congruence in modular arithmetic is an equation of the form. Why is the solution a set of integers rather than a unique integer?

3. pour from one decanter to the other until either the receiving decanter is full or the poured decanter is empty.

D-MATH Algebra I HS18 Prof. Rahul Pandharipande. Solution 1. Arithmetic, Zorn s Lemma.

0 Sets and Induction. Sets

Lecture 2. The Euclidean Algorithm and Numbers in Other Bases

Introduction to Sets and Logic (MATH 1190)

ICS141: Discrete Mathematics for Computer Science I

Induction and recursion. Chapter 5

SOLUTIONS Math 345 Homework 6 10/11/2017. Exercise 23. (a) Solve the following congruences: (i) x (mod 12) Answer. We have

The Fundamental Theorem of Arithmetic

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

Math.3336: Discrete Mathematics. Primes and Greatest Common Divisors

MTH 310, Section 001 Abstract Algebra I and Number Theory. Sample Midterm 1

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

Transcription:

Mathematics for Computer Science Exercises for Week 10 Silvio Capobianco Last update: 7 November 2018 Problems from Section 9.1 Problem 9.1. Prove that a linear combination of linear combinations of integers a 0,..., a n is a linear combination of a 0,..., a n. Solution. Suppose we have k 2 linear combinations L i = n j=0 s i,ja j. Given k integers b 1,..., b k, we want to show that L = k i=1 L k is also a linear combination of a 0,..., a n. We can do so by exploiting the commutative, associative, and distributive property: ( k k n ) b i L i = b i s i,j a j i=1 i=1 j=0 ( k n ) = b i s i,j a j = = i=1 j=0 ( n k ) b i s i,j a j j=0 i=1 ( n k ) b i s i,j a j j=0 i=1 which is indeed a linear combination of the a j s. 1

Problem 9.2. A number is perfect if it is equal to the sum of its positive divisors, other than itself. For example, 6 is perfect, because 6 = 1 + 2 + 3. Similarly, 28 is perfect, because 28 = 1 + 2 + 4 + 7 + 14. Explain why 2 k 1 (2 k 1) is perfect when 2 k 1 is prime. Solution. If 2 k 1 is prime, then every positive factor d of n = 2 k 1 (2 k 1) which is different from n is: 1. either a power 2 i of 2 with i [0..k 1] (for i = 0 this also covers the case d = 1), 2. or a product of the form 2 j (2 k 1) with j [0..k 2]. The sum of the factor of the first kind is k 1 i=0 2i = 2 k 1 (remember that k 1 i=0 ai = ak 1 for every a 1) while the sum of the factors of the second a 1 kind is (2 k 1) k 2 j=0 2j = (2 k 1) (2 k 1 1). Then the sum of all positive factors of 2 j (2 k 1), except itself, is: k 1 k 2 2 i + (2 k 1) 2 j = (2 k 1) + (2 k 1)(2 k 1 1) = 2 k 1 (2 k 1) = n. i=0 j=0 Problems for Section 9.2. Problem 9.3. Let x ::= 21212121, y ::= 12121212. Use the Euclidean algorithm to find the GCD of x and y. Hint: Looks scary, but it s not. Solution. The situation is not scary, because 21212121 = 21 1010101 and 12121212 = 12 1010101, which makes computing the GCD much less scary 2

than it seems: gcd(21212121, 12121212) = gcd(12121212, 9090909) = gcd(9090909, 3030303) = gcd(3030303, 0) = 3030303. Problem 9.4. Let x ::= 17 88 31 5 37 2 59 1000 y ::= 19 (922) 37 12 53 3678 59 29. (a) What is gcd(x, y)? (a) What is lcm(x, y)? ( lcm is the least common multiple.) Solution. (a) We use this exercise to introduce an important principle: the greatest common divisor of two numbers, expressed as products of powers of primes, is the product of the common prime factors of the two numbers, each appearing with the lowest exponent of those that appear in the factorizations of the two numbers. Here, the common prime factors are 37 and 59. 37 appears with exponent 2 in x and 12 in y, so it will appear with exponent 2 in gcd(x, y). 59 appears with exponent 1000 in x and 29 in y, so it will appear with exponent 29 in gcd(x, y). In conclusion, gcd(x, y) = 37 2 59 29. (b) For the least common multiple, we use a dual argument: it will be the product of those primes which appear in at least one factorization, each with the highest exponent of those that appear in the factorizations of the two numbers. In our case, lcm(x, y) = 17 88 19 (922) 31 5 37 12 53 3678 59 1000 Alternatively, we can observe that, whatever the positive integers x and y are, the following holds: x y = gcd(x, y) lcm(x, y) 3

Problem 9.5. Show that the following are equivalent: 1. There exists an integer x such that ax = qn + b. 2. gcd(a, n) b. Solution. If ax = qn + b for some integer x, then b = ax qn is a linear combination of a and n, and is thus divisible by gcd(a, n). If b = k gcd(a, n), for a suitable integer k, write gcd(a, n) = sa + tn according to Bézout s theorem: then b = ksa + ktn and we can take x = ks. Problem 9.8. (a) Use the Pulverizer to find integers x, y such that x30 + y22 = gcd(30, 22). (b) Now find integers x, y with 0 y < 30 such that x30 + y22 = gcd(30, 22). Solution. (a) Let us start the Pulverizer: a b rem(a, b) = a qcnt(a, b) b 30 22 8 = 30 22 22 8 6 = 22 2 8 = 22 2 (30 22) = 2 30 + 3 22 8 6 2 = 8 6 = (30 22) ( 2 30 + 3 22) = 3 30 4 22 6 2 0 Then gcd(30, 22) = 2 and we can choose x = 3, y = 4. (b) Of course, gcd(30, 22) 30 22 + 30 22 = gcd(30, 22): we can obtain the 30 22 by decreasing x by 22, and the +30 22 by increasing y by 30. That is, for x = x 22 = 19 and y = y + 30 = 26 we still have gcd(30, 22) = x 30 + y 22. As it turns out, 19 30 = 570 and 26 22 = 572. 4

Problem 9.9. (a) Use the Pulverizer to find gcd(84, 108). (b) Find integers x, y with 0 y < 84 such that x 84 + y 108 = gcd(84, 108). (c) Is there an integer k such that rem(84k, 108) = 1? Solution. (a) Let us start the Pulverizer: a b rem(a, b) = a qcnt(a, b) b 84 108 84 = 84 0 108 108 84 24 = 108 84 84 24 12 = 84 3 24 = 84 3 (108 84) = 4 84 3 108 24 12 0 Then gcd(84, 108) = 12 and we can choose x = 4, y = 3. (b) Of course, gcd(84, 108) 84 108 + 84 108 = gcd(84, 108): we can obtain the 84 108 by decreasing x by 108, and the +84 108 by increasing y by 84. That is, for x = 4 108 = 104 and y = 3 + 84 = 81 we still have gcd(84, 108) = x 84 + y 108. As it turns out, 84 104 = 8736 and 81 108 = 8748. (c) If such k existed, then k 84 qcnt(k 84, 108) 108 = 1 would be a linear combination of 84 and 108, hence be a multiple of gcd(84, 108): this is not the case, as the latter is 12. Problem 9.10. Indicate true or false for the following statements about the greatest common divisor, and provide counterexamples for those that are false. 1. If gcd(a, b) 1 and gcd(b, c) 1 then gcd(a, c) 1. 2. If a bc and gcd(a, b) = 1 then a c. 3. gcd(a n, b n ) = (gcd(a, b)) n. 4. gcd(ab, ac) = a gcd(b, c). 5

5. gcd(1 + a, 1 + b) = 1 + gcd(a, b). 6. If an integer linear combination of a and b equals 1, then so does some integer linear combination of a and b 2. 7. If no integer linear combination of a and b equals 2, then neither does any integer linear combination of a 2 and b 2. Solution. We are making the silent assumption that all the integers considered are positive. 1. False: gcd(4, 6) = 2 and gcd(6, 9) = 3, but gcd(4, 9) = 1. 2. True: this generalizes Lemma 9.4.2 to arbitrary integers. The proof is the same. 3. True: a full proof requires the Fundamental Theorem of Arithmetics, but the exercise does not require to prove true statements, only to provide counterexamples to false ones. 4. True: every common divisor of ab and ac is the product of a divisor of a and a common divisor of b and c, and the maximum such product is a gcd(b, c). 5. False: for a = 4 and b = 6 we have gcd(1 + a, 1 + b) = gcd(5, 7) = 1, but 1 + gcd(4, 6) = 1 + 2 = 3. 6. Yes: if sa + tb = 1 with s and t integers, then gcd(a, b) = 1, so gcd(a, b 2 ) = 1 too, because any prime that divides b 2 also divides b. 7. Yes: in the given hypothesis, gcd(a, b) 3, so gcd(a 2, b 2 ) 9 (simply because, if d n, then d 2 n 2 ) and any positive linear combination of a 2 and b 2 will be 9 or more. Problem 9.12. Here is a game you can analyze with number theory and always beat me. We start with two distinct, positive integers written on a blackboard. Call them a and b. Now we take turns. (I ll let you decide who goes first.) On each turn, the player must write a new positive integer on the board that is 6

the difference of two numbers that are already there. If a player cannot play, then they lose. For example, suppose that 12 and 15 are on the board initially. Your first play must be 3, which is 15 12. Then I might play 9, which is 12 3. Then you might play 6, which is 15 9. Then I can t play, so I lose. (a) Show that every number on the board at the end of the game is a multiple of gcd(a, b). (b) Show that every positive multiple of gcd(a, b) up to max(a, b) is on the board at the end of the game. (c) Describe a strategy that lets you win this game every time. Solution. (a) Let P (n) be the predicate: If the game has reached the nth move, then every number on the board is a multiple of gcd(a, b). We prove by induction that P (n) is true for every n N. Base case: n = 0. Then the only numbers on the board are a and b, which are divisible by gcd(a, b). Induction step: Suppose that, when the game has reached the nth move, all the numbers on the board are multiple of gcd(a, b). Two cases are possible: 1. If no more moves are possible, then P (n + 1) is trivially true as the game doesn t reach the (n + 1)st move. 2. If some moves are possible, then the new number of the board is the difference of some multiple of gcd(a, b), thus still a multiple of gcd(a, b) (b) We first observe that every number of the board must be a linear combination of a and b: equivalently, a multiple of gcd(a, b). If we manage to prove that gcd(a, b) can be put on the board, it will follow that every positive multiple of gcd(a, b) up to max(a, b) can be put on the board: for example, as an element of the sequence max(a, b), max(a, b) gcd(a, b), max(a, b) 2 gcd(a, b),... And this can be done, basically, with the Euclidean algorithm! To fix ideas, suppose a > b. First, build the sequence a, a b, a 2b,..., a qcnt(a, b)b = rem(a, b) = c; 7

next, build the sequence b, b c, b 2c,..., b qcnt(b, c) = rem(b, c) = d, skipping those numbers which have already been reached; and so on, until the Euclidean algorithm would stop. The number reached at that point must be gcd(a, b). (c) Divide max(a, b) by gcd(a, b): the result is the number of numbers on the board at the end of the game, and this is two more than the number of moves, as a and b are on the board from the start. If the result is odd, you take the first move; if the result is even, you leave the first move to me. This ensures that the last move is yours, and you win the game. Problems for Section 9.4 Problem 9.23. Let p be a prime number and a 1,..., a n integers. Prove the following Lemma by induction: Lemma. If p divides a product a 1 a n, then it divides some a i. You may assume the case for n = 2 which was given by Lemma 9.4.2. Be sure to clearly state and label your Induction Hypothesis, Base case(s), and Induction step. Solution. Let P (n) be the following predicate: for every prime p and integers a 1,..., a n, if p a 1 a n, then there exists i [1..n] such that p a i. We want to prove that P (n) is true for every n 1. (For n = 0 the empty product is 1, p does not divide 1, and P (0) is trivially true.) Base case: n = 1. Nothing to say: if p a 1, then p a 1. Induction step: suppose P (n) is true for some n 1. Let a = a 1 a n and b = a n+1. Two cases are possible: 1. p a. Then, by inductive hypothesis, p a i for some i [1..n]. 8

2. p a. Then p b: but b = a n+1. In either case, p a i for some i [1..n + 1]. There are no special hypotheses on n except that n 1, so indeed P (n) implies P (n + 1) for every n 1. By induction, we conclude that P (n) is true for every n 1. 9