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.

3.2 Sieving 125<br />

noticed that it was essentially sufficient to sieve just the odd numbers up to<br />

N when searching for primes.<br />

To sieve the sequence f(1),f(2),...,f(N), we initialize with ones an array<br />

corresponding to the numbers 1, 2,...,N. An important observation is that<br />

if p is prime and a satisfies f(a) ≡ 0(modp), then f(a + kp) ≡ 0(modp)<br />

for every integer k. Of course, there may be as many as degf such solutions<br />

a, and hence just as many distinct arithmetic progressions {a + kp} for each<br />

sieving prime p.<br />

Let us illustrate with the polynomial f(x) =x 2 + 1. We wish to find the<br />

primes of the form x 2 +1 for x an integer, 1 ≤ x ≤ N. For each prime p ≤ N,<br />

solve the congruence x 2 +1 ≡ 0(modp) (see Section 2.3.2). When p ≡ 1<br />

(mod 4), there are two solutions, when p ≡ 3 (mod 4), there are no solutions,<br />

and when p = 2 there is exactly one solution. For each prime p and solution<br />

a (that is, a 2 +1≡ 0(modp) and1≤ a

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

Saved successfully!

Ooh no, something went wrong!