1 / 13

Detecting Primes

Detecting Primes. Adam Brooks COT4810 February 12, 2008. Quick Number Theory Review. Prime number A natural number > 1 which has exactly two divisors – 1 and itself Composite number A non-prime number… a natural number that has a positive factor other than 1 and itself.

zed
Télécharger la présentation

Detecting Primes

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Detecting Primes Adam Brooks COT4810 February 12, 2008

  2. Quick Number Theory Review • Prime number • A natural number > 1 which has exactly two divisors – 1 and itself • Composite number • A non-prime number… a natural number that has a positive factor other than 1 and itself

  3. Application of Primes • Computer Science applies prime numbers in: • Cryptography • Hashing schemes • Sorting schemes • Random number generation

  4. Algorithms • Numerous algorithms exist for detecting if a given number is prime or composite. • Finding primes vs. testing if a number is prime • Deterministic tests vs. Probabilistic (Monte-Carlo) tests

  5. Sieve of Eratosthenes • Ancient Greek algorithm for identifying primes from 2..n • Steps: • Start with 2 and strike-out all multiples in the list • The first remaining number (3) is prime, strike-out it’s multiples and repeat the process

  6. Fermat’s Theorem • Probabilistic test to determine if a number n is prime. • Repeated k times for randomly selected integers in the range [1, n) • If the equality an-1 mod n = 1 fails, then a is said to be a witness for the compositeness of n.

  7. Rabin-Miller Test • Probabilistic (normally) method similar to Fermat’s where “witnesses” to a number’s compositeness are identified • A witness would be any integer w satisfying the following two conditions: 1. wn-1 = 1 mod n, or 2. For some integer k, and 1 < gcd(wn – 1, n) < n

  8. Rabin-Miller Test (cont.) • A simple algorithm can be outlined: • Input prime candidate n • Select m integers w1, w2, …, wm at random from the set {2, 3, …, n – 1} • For i = 1, 2, …, m, test whether wi is a witness • If none of the m integers are witnesses output yes, else, output no.

  9. Rabin-Miller Test (cont.) • How accurate is it? • Rabin theorized that if n is composite, more than half the numbers in the set {2, 3, …, n – 1} are witnesses to the compositeness of n. • The probability of n being prime if the algorithm returns yes is: • Where m is the number of random integers selected to test as witnesses.

  10. Special Primes • Probabilistic algorithms are useful in the search for primes due to the large numbers of computations required to find them… • GIMPS (Great Internet Mersenne Prime Search) is a Distributed Computing project supporting the search for Mersenne primes – of the form 2p – 1. • The largest known prime is traditionally a Mersenne prime.

  11. Mersenne Primes • The current largest prime (found in Sept. 2006) is the 44th known Mersenne prime, 232,582,657– 1 and is 9,808,358 digits long. • mersenne.org and the EFF currently offer prizes for finding the largest primes ($100,000 for the first 10,000,000 digit prime) • The bad news: • Testing a single 10,000,000+ digit number takes two months on a 2GHz P4

  12. Homework Questions • What form do Mersenne primes take? • Give two uses for prime numbers in computer science applications.

  13. References • Dewdney, A.K. The New Turing Omnibus. pp 335-338. • Rabin, Michael O. “Probabilistic algorithm for testing primality.” Journal of Number Theory, volume 12, issue 1. February, 1980. pp 128-138. • GIMPS – The Great Internet Mersenne Prime Search. http://www.mersenne.org • Bernstein, D.J. Distinguishing prime numbers from composite numbers: the state of the art in 2004. http://cr.yp.to/primetests.html • Prime Numbers. http://en.wikipedia.org/wiki/Prime_numbers

More Related