CSE 311 Foundations of Computing I

Slides:



Advertisements
Similar presentations
Euclidean Algorithm Applied Symbolic Computation CS 567 Jeremy Johnson.
Advertisements

1 Lect. 12: Number Theory. Contents Prime and Relative Prime Numbers Modular Arithmetic Fermat’s and Euler’s Theorem Extended Euclid’s Algorithm.
CS 202 Epp section ?? Aaron Bloomfield
The Integers and Division. Outline Division: Factors, multiples Exercise 2.3 Primes: The Fundamental Theorem of Arithmetic. The Division Algorithm Greatest.
CSE115/ENGR160 Discrete Mathematics 03/15/12
Sets, Combinatorics, Probability, and Number Theory Mathematical Structures for Computer Science Chapter 3 Copyright © 2006 W.H. Freeman & Co.MSCS Slides.
CSE 311 Foundations of Computing I Lecture 13 Number Theory Autumn 2012 CSE
Chapter Primes and Greatest Common Divisors ‒Primes ‒Greatest common divisors and least common multiples 1.
February 19, 2015Applied Discrete Mathematics Week 4: Number Theory 1 The Growth of Functions Question: If f(x) is O(x 2 ), is it also O(x 3 )? Yes. x.
22C:19 Discrete Math Integers and Modular Arithmetic Fall 2010 Sukumar Ghosh.
Notation Intro. Number Theory Online Cryptography Course Dan Boneh
6/20/2015 5:05 AMNumerical Algorithms1 x x1x
CSE 321 Discrete Structures Winter 2008 Lecture 8 Number Theory: Modular Arithmetic.
1 Integers and Division CS/APMA 202 Rosen section 2.4 Aaron Bloomfield.
CSE 321 Discrete Structures Winter 2008 Lecture 10 Number Theory: Primality.
CSE 311 Foundations of Computing I Lecture 12 Primes, GCD, Modular Inverse Spring
Fall 2002CMSC Discrete Structures1 Let us get into… Number Theory.
CS555Spring 2012/Topic 61 Cryptography CS 555 Topic 6: Number Theory Basics.
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 3 (Part 2): The Fundamentals: Algorithms, the.
1 Properties of Integers Objectives At the end of this unit, students should be able to: State the division algorithm Apply the division algorithm Find.
Module :MA3036NI Cryptography and Number Theory Lecture Week 7
CS 312: Algorithm Analysis Lecture #4: Primality Testing, GCD This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.Creative.
CompSci 102 Discrete Math for Computer Science
CS 312: Algorithm Analysis Lecture #4: Primality Testing, GCD This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.Creative.
Chapter 2 (Part 1): The Fundamentals: Algorithms, the Integers & Matrices The Integers and Division (Section 2.4)
CSE 311: Foundations of Computing Fall 2014 Lecture 12: Primes, GCD.
Information Security Lab. Dept. of Computer Engineering 87/121 PART I Symmetric Ciphers CHAPTER 4 Finite Fields 4.1 Groups, Rings, and Fields 4.2 Modular.
CS Modular Division and RSA1 RSA Public Key Encryption To do RSA we need fast Modular Exponentiation and Primality generation which we have shown.
MA/CSSE 473 Day 08 Extended Euclid's Algorithm Modular Division Fermat's little theorem.
Notation Intro. Number Theory Online Cryptography Course Dan Boneh
CSE 311 Foundations of Computing I Lecture 14 Euclid’s Algorithm Mathematical Induction Autumn 2012 CSE
Ch1 - Algorithms with numbers Basic arithmetic Basic arithmetic Addition Addition Multiplication Multiplication Division Division Modular arithmetic Modular.
Application: Algorithms Lecture 20 Section 3.8 Wed, Feb 21, 2007.
Ref: Pfleeger96, Ch.31 Properties of Arithmetic Reference: Pfleeger, Charles P., Security in Computing, 2nd Edition, Prentice Hall, 1996.
CSE 311: Foundations of Computing Fall 2013 Lecture 12: Primes, GCD, modular inverse.
CSE 311: Foundations of Computing Fall 2013 Lecture 11: Modular arithmetic and applications.
CS 312: Algorithm Analysis Lecture #4: Primality Testing, GCD This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.Creative.
1 Discrete Structures – CNS2300 Text Discrete Mathematics and Its Applications Kenneth H. Rosen (5 th Edition) Chapter 2 The Fundamentals: Algorithms,
Chapter 4 With Question/Answer Animations 1. Chapter Summary Divisibility and Modular Arithmetic - Sec 4.1 – Lecture 16 Integer Representations and Algorithms.
Ch04-Number Theory and Cryptography 1. Introduction to Number Theory Number theory is about integers and their properties. We will start with the basic.
Number Theory Lecture 1 Text book: Discrete Mathematics and its Applications, 7 th Edition.
CSE 311 Foundations of Computing I Lecture 12 Modular Arithmetic and Applications Autumn 2012 CSE
CSE 311 Foundations of Computing I Lecture 11 Modular Exponentiation and Primes Autumn 2011 CSE 3111.
MA/CSSE 473 Day 07 Extended Euclid's Algorithm Modular Division Fermat's little theorem intro.
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.
Number Theory. Introduction to Number Theory Number theory is about integers and their properties. We will start with the basic principles of divisibility,
Number-Theoretic Algorithms
MA/CSSE 473 Day 07 Extended Euclid's Algorithm Modular Division
CS 210 Discrete Mathematics The Integers and Division (Section 3.4)
B504/I538: Introduction to Cryptography
MA/CSSE 473 Day 06 Euclid's Algorithm.
CSE15 Discrete Mathematics 03/20/17
Number-Theoretic Algorithms (UNIT-4)
CSE 311 Foundations of Computing I
CSE 311 Foundations of Computing I
Applied Discrete Mathematics Week 3: Algorithms
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett
Number Theory (Chapter 7)
Number Theory.
Discrete Math for CS CMPSC 360 LECTURE 12 Last time: Stable matching
CSE 311 Foundations of Computing I
CSE 311: Foundations of Computing
CSE 321 Discrete Structures
CSE 321 Discrete Structures
CSE 321 Discrete Structures
Number Theory.
Useful GCD Fact If a and b are positive integers, then gcd(a,b) = gcd(b, a mod b) Proof: By definition of mod, a = qb+ (a mod b) for.
CSE 311 Foundations of Computing I
From the last time: gcd(a, b) can be characterized in two different ways: It is the least positive value of ax + by where x and y range over integers.
Sets, Combinatorics, Probability, and Number Theory
Presentation transcript:

CSE 311 Foundations of Computing I Lecture 12 GCD and Euclid’s Algorithm Autumn 2011 Autumn 2011 CSE 311

Announcements Reading assignments Today : 7th Edition: 4.3 (the rest of the chapter is interesting!) 6th Edition: 3.5, 3.6 5th Edition: 2.5, 2.6 up to p. 191 Wednesday 7th Edition: 5.1, 5.2 6th Edition: 4.1, 4.2 5th Edition: 3.3, 3.4 Updated slides from lectures 10 and 11 have been posted Paul out of town Monday, Richard out of town Friday Autumn 2011 CSE 311

Highlights from last lecture Applications of modular arithmetic Modular exponentiation Primality Autumn 2011 CSE 311

Fast exponentiation Autumn 2011 CSE 311

Primality An integer p greater than 1 is called prime if the only positive factors of p are 1 and p. A positive integer that is greater than 1 and is not prime is called composite. Every positive integer greater than 1 has a unique prime factorization Autumn 2011 CSE 311

Euclid’s theorem There are an infinite number of primes. Proof by contradiction: Suppose there are a finite number of primes: p1, p2, . . ., pn Autumn 2011 CSE 311

Distribution of Primes 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211 223 227 229 233 239 241 251 257 263 269 271 277 281 283 293 307 311 313 317 331 337 347 349 353 359 If you pick a random number n in the range [x, 2x], what is the chance that n is prime? Autumn 2011 CSE 311

Famous Algorithmic Problems Primality Testing: Given an integer n, determine if n is prime Factoring Given an integer n, determine the prime factorization of n Autumn 2011 CSE 311

Factoring Factor the following 232 digit number [RSA768]: 1230186684530117755130494958384962720772853569595334792197322452151726400507263657518745202199786469389956474942774063845925192557326303453731548268507917026122142913461670429214311602221240479274737794080665351419597459856902143413 Autumn 2011 CSE 311

1230186684530117755130494958384962720772853569595334792197322452151726400507263657518745202199786469389956474942774063845925192557326303453731548268507917026122142913461670429214311602221240479274737794080665351419597459856902143413 33478071698956898786044169848212690817704794983713768568912431388982883793878002287614711652531743087737814467999489 36746043666799590428244633799627952632279158164343087642676032283815739666511279233373417143396810270092798736308917 Autumn 2011 CSE 311

Greatest Common Divisor GCD(a, b): Largest integer d such that d|a and d|b GCD(100, 125) = GCD(17, 49) = GCD(11, 66) = GCD(180, 252) = Autumn 2011 CSE 311

GCD, LCM and Factoring a = 23 • 3 • 52 • 7 • 11 = 46,200 b = 2 • 32 • 53 • 7 • 13 = 204,750 GCD(a, b) = 2min(3,1) • 3min(1,2) • 5min(2,3) • 7min(1,1) • 11min(1,0) • 13min(0,1) LCM(a, b) = 2max(3,1) • 3max(1,2) • 5max(2,3) • 7max(1,1) • 11max(1,0) • 13max(0,1) Autumn 2011 CSE 311

Theorem Let a and b be positive integers. Then a • b = gcd(a, b) • lcm(a, b) Autumn 2011 CSE 311

Euclid’s Algorithm GCD(x, y) = GCD(y, x mod y) a = 98, b = 35 Example: GCD(660, 126) int GCD(int a, int b){ /* a >= b, b > 0 */ int tmp; int x = a; int y = b; while (y > 0){ tmp = x % y; x = y; y = tmp; } return x; Autumn 2011 CSE 311

Extended Euclid’s Algorithm If GCD(x, y) = g, there exist integers s, t, such sx + ty = g; The values x, y in Euclid’s algorithm are linear sums of a, b. A little book keeping can be used to keep track of the constants Autumn 2011 CSE 311

Bézout’s Theorem If a and b are positive integers, then there exist integers s and t such that gcd(a,b) = sa + tb. Autumn 2011 CSE 311

Simple cipher Caesar cipher, a → b, b → c, . . . Shift cipher HELLOWORLD → IFMMPXPSME Shift cipher f(x) = (x + k) mod 26 f-1(x) = (x – k) mod 26 f(x) = (ax + b) mod 26 How good is the cipher f(x) = (2x + 1) mod 26 Autumn 2011 CSE 311

Multiplicative Cipher: f(x) = ax mod m For a multiplicative cipher to be invertible: f(x) = ax mod m : {0, m-1} → {0, m-1} must be one to one and onto Lemma: If there is an integer b such that ab mod m = 1, then the function f(x) = ax mod m is one to one and onto. Autumn 2011 CSE 311

Multiplicative Inverse mod m Suppose GCD(a, m) = 1 By Bézoit’s Theorem, there exist integers s and t such that sa + tm = 1. s is the multiplicative inverse of a: 1 = (sa + tm) mod m = sa mod m Autumn 2011 CSE 311