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

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

Math.3336: Discrete Mathematics. Advanced Counting Techniques

4 Number Theory and Cryptography

3 The fundamentals: Algorithms, the integers, and matrices

Math.3336: Discrete Mathematics. Mathematical Induction

Math.3336: Discrete Mathematics. Cardinality of Sets

Math.3336: Discrete Mathematics. Chapter 9 Relations

Introduction to Sets and Logic (MATH 1190)

With Question/Answer Animations. Chapter 4

Math.3336: Discrete Mathematics. Propositional Equivalences

Slides by Christopher M. Bourke Instructor: Berthe Y. Choueiry. Spring 2006

Math.3336: Discrete Mathematics. Combinatorics: Basics of Counting

Review. CS311H: Discrete Mathematics. Number Theory. Computing GCDs. Insight Behind Euclid s Algorithm. Using this Theorem. Euclidian Algorithm

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

COT 3100 Applications of Discrete Structures Dr. Michael P. Frank

CISC-102 Fall 2017 Week 6

Ch 4.2 Divisibility Properties

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

NOTES ON SIMPLE NUMBER THEORY

4. Number Theory (Part 2)

Math.3336: Discrete Mathematics. Applications of Propositional Logic

Math.3336: Discrete Mathematics. Proof Methods and Strategy

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

Applied Cryptography and Computer Security CSE 664 Spring 2017

Introduction to Cryptography CS 355 Lecture 3

2 Elementary number theory

ECE 646 Lecture 5. Mathematical Background: Modular Arithmetic

Discrete Mathematics GCD, LCM, RSA Algorithm

Integers and Division

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

MATH 433 Applied Algebra Lecture 4: Modular arithmetic (continued). Linear congruences.

The Euclidean Algorithm and Multiplicative Inverses

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

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

4 Powers of an Element; Cyclic Groups

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

Math 131 notes. Jason Riedy. 6 October, Linear Diophantine equations : Likely delayed 6

CSE 20 DISCRETE MATH. Winter

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

Introduction Integers. Discrete Mathematics Andrei Bulatov

Number theory (Chapter 4)

Number Theory Proof Portfolio

Introduction to Number Theory

MATH 361: NUMBER THEORY FOURTH LECTURE

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

CS March 17, 2009

Chapter 5. Number Theory. 5.1 Base b representations

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.

Math.3336: Discrete Mathematics. Nested Quantifiers

Number Theory and Cryptography

Introduction to Number Theory. The study of the integers

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

Basic elements of number theory

Basic elements of number theory

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

Section Summary. Division Division Algorithm Modular Arithmetic

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

1 Overview and revision

cse547, math547 DISCRETE MATHEMATICS Professor Anita Wasilewska

Lecture 2. The Euclidean Algorithm and Numbers in Other Bases

Lecture 3.1: Public Key Cryptography I

Math.3336: Discrete Mathematics. Nested Quantifiers/Rules of Inference

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

Outline. Some Review: Divisors. Common Divisors. Primes and Factors. b divides a (or b is a divisor of a) if a = mb for some m

Outline. AIT 682: Network and Systems Security. GCD and Euclid s Algorithm Modulo Arithmetic Modular Exponentiation Discrete Logarithms

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

Notes on Systems of Linear Congruences

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

CMPUT 403: Number Theory

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

Number Theory and Divisibility

8 Primes and Modular Arithmetic

Course: CS1050c (Fall '03) Homework2 Solutions Instructor: Prasad Tetali TAs: Kim, Woo Young: Deeparnab Chakrabarty:

W3203 Discrete Mathema1cs. Number Theory. Spring 2015 Instructor: Ilia Vovsha. hcp://

Senior Math Circles Cryptography and Number Theory Week 2

Chapter 2 (Part 3): The Fundamentals: Algorithms, the Integers & Matrices. Integers & Algorithms (2.5)

Remainders. We learned how to multiply and divide in elementary

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

Ma/CS 6a Class 2: Congruences

Discrete Structures Lecture Primes and Greatest Common Divisor

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

Number Theory and Group Theoryfor Public-Key Cryptography

CSC 474 Network Security. Outline. GCD and Euclid s Algorithm. GCD and Euclid s Algorithm Modulo Arithmetic Modular Exponentiation Discrete Logarithms

Beautiful Mathematics

Number Theory. CSS322: Security and Cryptography. Sirindhorn International Institute of Technology Thammasat University CSS322. Number Theory.

This is a recursive algorithm. The procedure is guaranteed to terminate, since the second argument decreases each time.

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

Module 1. Integers, Induction, and Recurrences

M381 Number Theory 2004 Page 1

Lecture 4: Number theory

Number Theory Notes Spring 2011

C-N Math 207 Discrete Math

C-N Math 207 Discrete Math

Chapter 3 Basic Number Theory

Lecture 5: Arithmetic Modulo m, Primes and Greatest Common Divisors Lecturer: Lale Özkahya

Numbers. Çetin Kaya Koç Winter / 18

CPSC 467: Cryptography and Computer Security

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.

Transcription:

Math.3336: Discrete Mathematics Primes and Greatest Common Divisors Instructor: Dr. Blerina Xhabli Department of Mathematics, University of Houston https://www.math.uh.edu/ blerina Email: blerina@math.uh.edu Spring 2019 Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Primes and Greatest Common Divisors 1/26

Course Information/Office Hours Instructor: Dr. Blerina Xhabli Office hours: TuTh 10:30am 12:00pm (PGH 202) Tutor/Grader: An Vu Office hours: MonWed 2:30pm 4:00pm (Fleming #11) Class meets every TuTh 1:00 pm - 2:30 pm Course webpage: http://www.math.uh.edu/ blerina/ The class webpage contains contact info, office hours, slides from lectures, and important announcements. Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Primes and Greatest Common Divisors 2/26

Assignments to work on Homework #5 due Thursday, 3/07, 11:59pm No credit unless turned in by 11:59pm on due date Late submissions not allowed, but lowest homework score dropped when calculating grades Homework will be submitted online in your CASA accounts. You can find the instructions on how to upload your homework in our class webpage. Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Primes and Greatest Common Divisors 3/26

Chapter 4 Number Theory and Cryptography Chapter 4 Overview Divisibility and Modular Arithmetic Section 4.1 Integer Representations and Algorithms Section 4.2 Primes and Greatest Common Divisors Section 4.3 Solving Congruences Section 4.4 Applications of Congruences Section 4.5* Cryptography Section 4.6 Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Primes and Greatest Common Divisors 4/26

A review on Divisibility and Congruence Modulo Given two integers a and b where a 0, we say a divides b if there is an integer c such that b = ac If a divides b, we write a b; otherwise, a b If a b, a is called a factor of b and b is called a multiple of a. Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Primes and Greatest Common Divisors 5/26

Properties of Divisibility Theorem 1: If a b and a c, then a (b + c) Theorem 2: If a b, then a bc for all integers c Theorem 3: If a b and b c, then a c Theorem 4: If a b and a c, then a (mb + nc) Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Primes and Greatest Common Divisors 6/26

The Division Theorem Division theorem: Let a be an integer, and d a positive integer. Then, there are unique integers q, r with 0 r < d such that a = dq + r Here, d is called divisor, and a is called dividend q is the quotient, and r is the remainder. We use the r = a mod d notation to express the remainder The notation q = a div d expresses the quotient Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Primes and Greatest Common Divisors 7/26

Congruence Modulo a and b are congruent modulo m, a b (mod m) if and only if m (a b) Theorem: a b (mod m) iff a mod m = b mod m If a b (mod m) and c d (mod m) and k Z, then a + c b + d (mod m) a c b d (mod m) ac bd (mod m) a + k b + k (mod m) ak bk (mod m) Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Primes and Greatest Common Divisors 8/26

Section 4.2 Integer Representations and Algorithms Section Summary Integer Representations Base b Expansions Binary Expansions Octal Expansions Hexadecimal Expansions Base Conversion Algorithm Algorithms for Integer Operations Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Primes and Greatest Common Divisors 9/26

Section 4.3 Prime Numbers A positive integer p that is greater than 1 and divisible only by 1 and itself is called a prime number. First few primes: 2, 3, 5, 7, 11,... A positive integer that is greater than 1 and that is not prime is called a composite number Example: 4, 6, 8, 9,... Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Primes and Greatest Common Divisors 10/26

Fundamental Theorem of Arithmetic Fundamental Thm: Every positive integer greater than 1 is either prime or can be written uniquely as a product of primes. This unique product of prime numbers for x is called the prime factorization of x Examples: 12 = 2 2 3 21 = 3 7 99 = 3 3 11 Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Primes and Greatest Common Divisors 11/26

Determining Prime-ness In many applications, such as crypto, important to determine if a number is prime following thm is useful for this: Theorem: If n is composite, then it has a prime divisor less than or equal to n Proof: Since n is composite, it can be written as n = ab where a > 1 and b > 1. For contradiction, suppose neither a nor b are n, i.e., a > n, b > n Then, n = ab > n 2 = n, a contradiction. Hence, either a n, or b n, and by the Fundamental Thm, is either itself a prime or has a factor less than itself. Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Primes and Greatest Common Divisors 12/26

Consequence of This Theorem Theorem: If n is composite, then it has a prime divisor n Corollary: If n does not have a prime divisor n, then n is prime. Thus, to determine if n is prime, only need to check if it is divisible by primes n Example: Show that 101 is prime Since 101 < 11, only need to check if it is divisible by 2, 3, 5, 7. Since it is not divisible by any of these, we know it is prime. Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Primes and Greatest Common Divisors 13/26

Infinitely Many Primes Theorem: There are infinitely many prime numbers. Proof: (by contradiction) Suppose there are finitely many primes: p 1, p 2,..., p n Now consider the number Q = p 1 p 2... p n + 1. Q is either prime or composite Case 1: Q is prime. We get a contradiction, because we assumed only prime numbers are p 1,..., p n Case 2: Q is composite. In this case, Q can be written as product of primes. But Q is not divisible by any of p 1, p 2,..., p n Hence, by Fundamental Thm, not composite Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Primes and Greatest Common Divisors 14/26

Greatest Common Divisors Suppose a and b are integers, not both 0. Then, the largest integer d such that d a and d b is called greatest common divisor of a and b, written gcd(a,b). Example: gcd(24, 36) = 12 Example: gcd(2 3 5, 2 2 3) = 2 2 Example: gcd(14, 25) = 1 Two numbers whose gcd is 1 are called relatively prime. Example: 14 and 25 are relatively prime Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Primes and Greatest Common Divisors 15/26

Least Common Multiple The least common multiple of a and b, written lcm(a,b), is the smallest integer c such that a c and b c. Example: lcm(9, 12)= 36 Example: lcm(2 3 3 5 7 2, 2 4 3 3 )= 2 4 3 5 7 2 Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Primes and Greatest Common Divisors 16/26

Theorem about LCM and GCD Theorem: Let a and b be positive integers. Then, ab = gcd(a, b) lcm(a, b) Proof: Let a = p i 1 1 p i 2 2... pn in and b = p j 1 1 p j 2 2... pn jn Then, ab = p i 1+j 1 1 p i 2+j 2 2... p in +jn n gcd(a, b) = p min(i 1,j 1 ) 1 p min(i 2,j 2 ) 2... p lcm(a, b) = p max(i 1,j 1 ) 1 p max(i 2,j 2 ) 2... p min(in,jn ) n max(in,jn ) n Thus, we need to show i k + j k = min(i k, j k ) + max(i k, j k ) Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Primes and Greatest Common Divisors 17/26

Proof, cont. Show i k + j k = min(i k, j k ) + max(i k, j k ) Either (i) i k < j k or (ii) i k j k If (i), then min(i k, j k ) = i k and max(i k, j k ) = j k Thus, i k + j k = min(i k, j k ) + max(i k, j k ) If (ii), then min(i k, j k ) = j k and max(i k, j k ) = i k Hence min(i k, j k ) + max(i k, j k ) = i k + j k Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Primes and Greatest Common Divisors 18/26

Computing GCDs Simple algorithm to compute gcd of a, b: Factorize a as p i1 1 pi2 2... pin n Factorize b as p j1 1 pj2 2... pjn n gcd(a, b) = p min(i1,j1) 1 p min(i2,j2) 2... p min(in,jn ) n But this algorithm is not very practical because prime factorization is computationally expensive! Much more efficient algorithm to compute gcd, called the Euclidian algorithm Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Primes and Greatest Common Divisors 19/26

Insight Behind Euclid s Algorithm Theorem: Let a = bq + r. Then, gcd(a, b) = gcd(b, r) Proof: We ll show that a, b and b, r have the same common divisors implies they have the same gcd. Suppose d is a common divisor of a, b, i.e., d a and d b By theorem we proved earlier, this implies d a bq Since a bq = r, d r. Hence d is common divisor of b, r. Now, suppose d b and d r. Then, d bq + r Hence, d a and d is common divisor of a, b Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Primes and Greatest Common Divisors 20/26

Using this Theorem Theorem: Let a = bq + r. Then, gcd(a, b) = gcd(b, r) Theorem suggests following strategy to compute gcd(a, b): Compute r 1 = a mod b (gcd(a, b) = gcd(b, r 1 )) Compute r 2 = b mod r 1 (gcd(a, b) = gcd(r 1, r 2 )) Compute r 3 = r 1 mod r 2 (gcd(a, b) = gcd(r 2, r 3 )) Repeat until remainder becomes 0 (gcd(a, b) = gcd(r n, 0) = r n ) The last non-zero remainder is the gcd of a and b! Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Primes and Greatest Common Divisors 21/26

Euclidian Algorithm Find gcd of 72 and 20 12 = 72 mod 20 8 = 20 mod 12 4 = 12 mod 8 0 = 8 mod 4 gcd is 4! Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Primes and Greatest Common Divisors 22/26

Euclidean Algorithm Example Find gcd of 662 and 414 248 = 662 mod 414 166 = 414 mod 248 82 = 248 mod 166 2 = 166 mod 82 0 = 82 mod 2 gcd is 2! Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Primes and Greatest Common Divisors 23/26

GCD as Linear Combination gcd(a, b) can be expressed as a linear combination of a and b Bezout s Theorem: If a and b are positive integers, then there exist integers s and t such that: gcd(a, b) = s a + t b. This is called the Bezout s identity, and s and t are the Bezout s coefficients. Furthermore, Euclidean algorithm gives us a way to compute these integers s and t Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Primes and Greatest Common Divisors 24/26

Example Express gcd(252, 198) as a linear combination of 252 and 198 First apply Euclid s algorithm (write a = bq + r at each step): 1 252 = 1 198 + 54 2 198 = 3 54 + 36 3 54 = 1 36 + 18 4 36 = 2 18 + 0 gcd is 18 Now, using (3), write 18 as 54 1 36 Using (2), write 18 as 54 1 (198 3 54) Using (1), we have 54 = 252 1 198, thus: 18 = (252 1 198) 1(198 3 (252 1 198)) Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Primes and Greatest Common Divisors 25/26

Example, cont. 18 = (252 1 198) 1(198 3 (252 1 198)) Now, let s simplify this: 18 = 252 1 198 1 198 + 3 252 3 198 Now, collect all 252 and 198 terms together: 18 = 4 252 5 198 Trace steps of Euclid s algorithm backwards to derive s, t: gcd(a, b) = s a + t b This is known as the extended Euclidian algorithm Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Primes and Greatest Common Divisors 26/26