Download presentation
Presentation is loading. Please wait.
Published byBennett Fowler Modified over 9 years ago
1
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett
2
Today’s Topics: 1. Prime factorization 2. Primality testing 2
3
1. Prime factorizations Primes are the atoms of integers 3
4
Primes 4
5
Which of the following is prime? A. 1 B. 6 C. 7 D. 21 5
6
Prime factorization Basic theorem of number theory: any integer can be factored as a product of primes (we will prove this soon) Moreover, this factorization is unique Example: 36=2*2*3*3 6
7
Existence of prime factorization 7
8
8
9
How to find the prime factorization? What is the prime factorization of 100? A. 2*5 B. 2*2*5 C. 10*10 D. 2*2*5*5 E. Other 9
10
How to find the prime factorization? What is the prime factorization of 82768328638217? 10
11
How to find the prime factorization? What is the prime factorization of 82768328638217? Not so easy anymore… The security of RSA (which for example, protects your bank accounts) is based on the assumption that it is hard to factor numbers We cannot prove it. In fact, maybe somebody knows how to factor numbers fast (lets wait for more Snowden revelations…) 11
12
2. Primality testing 12
13
Primality testing If it’s hard to factor numbers into primes, lets focus on an easier problem Test if a given integer is prime How can you do it? Try and come up with the best algorithm you can 13
14
Primality testing Algorithm 1: isPrime(n): 1. For i=2..n-1 1.1 If n MOD i=0: return False 2. Return True 14
15
Primality testing Algorithm 1: isPrime(n): 1. For i=2..n-1 1.1 If n MOD i=0: return False 2. Return True 15 How many steps? A. ~n B. ~n 2 C. ~log(n) D. Doesn’t depend on n E. Other
16
Better primality testing? 16
17
Primality testing Algorithm 1: isPrime(n): 1. For i=2..n-1 1.1 If n MOD i=0: return False 2. Return True 17
18
Primality testing (II) 18
19
Primality testing (II) 19 How many steps? A. ~n B. ~n 2 C. ~log(n) D. Doesn’t depend on n E. Other
20
An even faster algorithm? The prime numbers used in RSA are very big, with 100s of digits These algorithms will take forever There are much faster algorithms, which run in time ~log(n); they are randomized algorithm (e.g. Miller-Rabin) 20
21
Log vs poly time 21
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.