10.12.2012 Views

Prime Numbers

Prime Numbers

Prime Numbers

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

126 Chapter 3 RECOGNIZING PRIMES AND COMPOSITES<br />

It is important to be able to sieve the consecutive values of a polynomial<br />

for B-smooth numbers, as in Section 3.2.5. All of the ideas of that section<br />

port most naturally to the ideas of this section.<br />

3.2.7 Theoretical considerations<br />

The complexity N ln ln N of the sieve of Eratosthenes may be reduced<br />

somewhat by several clever arguments. The following algorithm is based<br />

on ideas of Mairson and Pritchard (see [Pritchard 1981]). It requires only<br />

O(N/ ln ln N) steps, where each step is either for bookkeeping or an addition<br />

with integers at most N. (Note that an explicit pseudocode display for a<br />

rudimentary Eratosthenes sieve appears in Section 3.2.2.)<br />

Algorithm 3.2.2 (Fancy Eratosthenes sieve). We are given a number N ≥<br />

4. This algorithm finds the set of primes in [1,N]. Letpl denote the l-th prime,<br />

let Ml = p1p2 ···pl, and let Sl denote the set of numbers in [1,N] that are<br />

coprime to Ml. Note that if pm+1 > √ N, then the set of primes in [1,N] is<br />

(Sm \{1}) ∪{p1,p2,...,pm}. The algorithm recursively finds Sk,Sk+1,...,Sm<br />

starting from a moderately sized initial value k and ending with m = π( √ N).<br />

1. [Setup]<br />

Set k as the integer with Mk ≤ N/ ln N

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!