Modular Arithmetic and Primality
Modular Arithmetic and Primality Modular Arithmetic and Primality
function primality2(N) Input: Positive integer N Output: yes/no Choose a 1 …a k (k
Primality testing is efficient! - O(n 3 ) Carmichael numbers – There are an infinite but rare set of composite numbers which pass the Fermat test for all a i – These can be dealt with by a more refined primality test Generating random primes – An n bit random number has approximately a 1 in n chance of being prime Prime Generation Algorithm CS 312 - Complexity Examples - Arithmetic and RSA 33
- Page 1 and 2: Addition Multiplication Bigger Ex
- Page 3 and 4: Addition of two numbers of length n
- Page 5 and 6: Addition of two numbers of length n
- Page 7 and 8: Isn’t addition in a computer just
- Page 9 and 10: x y 15 11 At each step double x and
- Page 11 and 12: ⎧⎧ 2(x⋅ ⎣⎣y/2⎦⎦) if y
- Page 13 and 14: x y y binary # of x’s 15 8 0 1 30
- Page 15 and 16: function multiply(x,y) Input: Two n
- Page 17 and 18: Is multiplication O(n 2 ) - Could w
- Page 19 and 20: Assume we start with numbers Mod N
- Page 21 and 22: There is a faster algorithm - Rathe
- Page 23 and 24: ⎧⎧ (x ⎣⎣y/2⎦⎦ ) 2 if y
- Page 25 and 26: x y y binary power of x z return va
- Page 27 and 28: function modexp (x, y, N) //Iterati
- Page 29 and 30: function primality(N) Input: Positi
- Page 31: How often does a composite number c
function primality2(N)<br />
Input: Positive integer N<br />
Output: yes/no<br />
Choose a 1 …a k (k