Prime Numbers
Prime Numbers Prime Numbers
3.7 Counting primes 153 Label the consecutive primes p1,p2,p3,...,wherep1 =2,p2 =3,p3 =5, etc. Let φ(x, y) =#{1 ≤ n ≤ x : each prime dividing n is greater than y}. Thus φ(x, pa) is the number of integers left unmarked in the sieve of Eratosthenes, applied to the interval [1,x], after sieving with p1,p2,...,pa. Since sieving up to √ x leaves only the number 1 and the primes in ( √ x, x], we have π(x) − π √ x +1=φ x, √ x . One could easily use this idea to compute π(x), the time taking O(x ln ln x) operations and, if the sieve is segmented, taking O x 1/2 ln x space. (We shall begin suppressing ln x and ln ln x factors for simplicity, sweeping them under a rather large rug of O(x ɛ ). It will be clear that each x ɛ could be replaced, with a little more work, with a small power of logarithm and/or double logarithm.) A key thought is that the sieve not only allows us to count the primes, it also identifies them. If it is only the count we are after, then perhaps we can be speedier. We shall partition the numbers counted by φ(x, y) by the number of prime factors they have, counted with multiplicity. Let φk(x, y) =#{n ≤ x : n has exactly k prime factors, each exceeding y}. Thus, if x ≥ 1, φ0(x, y) is1,φ1(x, y) is the number of primes in (y, x], φ2(x, y) is the number of numbers pq ≤ x where p, q areprimeswithy
154 Chapter 3 RECOGNIZING PRIMES AND COMPOSITES allowed to run over the interval [p, x/p], and so the number of choices for q is π(x/p) − π(p) + 1. Thus, φ2(x, x 1/3 )= (π(x/p) − π(p)+1) The last sum is = π(x 1/3 )
- Page 116 and 117: 102 Chapter 2 NUMBER-THEORETICAL TO
- Page 118 and 119: 104 Chapter 2 NUMBER-THEORETICAL TO
- Page 120 and 121: 106 Chapter 2 NUMBER-THEORETICAL TO
- Page 122 and 123: 108 Chapter 2 NUMBER-THEORETICAL TO
- Page 124 and 125: 110 Chapter 2 NUMBER-THEORETICAL TO
- Page 126 and 127: 112 Chapter 2 NUMBER-THEORETICAL TO
- Page 128 and 129: 114 Chapter 2 NUMBER-THEORETICAL TO
- Page 130 and 131: Chapter 3 RECOGNIZING PRIMES AND CO
- Page 132 and 133: 3.1 Trial division 119 d =3; while(
- Page 134 and 135: 3.2 Sieving 121 3.2 Sieving Sieving
- Page 136 and 137: 3.2 Sieving 123 this number’s ent
- Page 138 and 139: 3.2 Sieving 125 noticed that it was
- Page 140 and 141: 3.2 Sieving 127 } S = S \ (pS ∩ [
- Page 142 and 143: 3.3 Recognizing smooth numbers 129
- Page 144 and 145: 3.4 Pseudoprimes 131 } g =gcd(s, x)
- Page 146 and 147: 3.4 Pseudoprimes 133 Theorem 3.4.4.
- Page 148 and 149: 3.5 Probable primes and witnesses 1
- Page 150 and 151: 3.5 Probable primes and witnesses 1
- Page 152 and 153: 3.5 Probable primes and witnesses 1
- Page 154 and 155: 3.5 Probable primes and witnesses 1
- Page 156 and 157: 3.6 Lucas pseudoprimes 143 The Fibo
- Page 158 and 159: 3.6 Lucas pseudoprimes 145 Because
- Page 160 and 161: 3.6 Lucas pseudoprimes 147 use (3.1
- Page 162 and 163: 3.6 Lucas pseudoprimes 149 gcd(n, 2
- Page 164 and 165: 3.6 Lucas pseudoprimes 151 Theorem
- Page 168 and 169: 3.7 Counting primes 155 for b ≥ 2
- Page 170 and 171: 3.7 Counting primes 157 The heart o
- Page 172 and 173: 3.7 Counting primes 159 t =Im(s) ra
- Page 174 and 175: 3.7 Counting primes 161 Indeed, the
- Page 176 and 177: 3.8 Exercises 163 3.3. Prove that i
- Page 178 and 179: 3.8 Exercises 165 3.12. Show that a
- Page 180 and 181: 3.8 Exercises 167 3.28. Show that t
- Page 182 and 183: 3.9 Research problems 169 with W (n
- Page 184 and 185: 3.9 Research problems 171 3.50. The
- Page 186 and 187: 174 Chapter 4 PRIMALITY PROVING Rem
- Page 188 and 189: 176 Chapter 4 PRIMALITY PROVING sma
- Page 190 and 191: 178 Chapter 4 PRIMALITY PROVING Sin
- Page 192 and 193: 180 Chapter 4 PRIMALITY PROVING Let
- Page 194 and 195: 182 Chapter 4 PRIMALITY PROVING Rec
- Page 196 and 197: 184 Chapter 4 PRIMALITY PROVING (mo
- Page 198 and 199: 186 Chapter 4 PRIMALITY PROVING pol
- Page 200 and 201: 188 Chapter 4 PRIMALITY PROVING if
- Page 202 and 203: 190 Chapter 4 PRIMALITY PROVING 4.3
- Page 204 and 205: 192 Chapter 4 PRIMALITY PROVING j =
- Page 206 and 207: 194 Chapter 4 PRIMALITY PROVING The
- Page 208 and 209: 196 Chapter 4 PRIMALITY PROVING The
- Page 210 and 211: 198 Chapter 4 PRIMALITY PROVING Rem
- Page 212 and 213: 200 Chapter 4 PRIMALITY PROVING pos
- Page 214 and 215: 202 Chapter 4 PRIMALITY PROVING Alg
3.7 Counting primes 153<br />
Label the consecutive primes p1,p2,p3,...,wherep1 =2,p2 =3,p3 =5,<br />
etc. Let<br />
φ(x, y) =#{1 ≤ n ≤ x : each prime dividing n is greater than y}.<br />
Thus φ(x, pa) is the number of integers left unmarked in the sieve of<br />
Eratosthenes, applied to the interval [1,x], after sieving with p1,p2,...,pa.<br />
Since sieving up to √ x leaves only the number 1 and the primes in ( √ x, x],<br />
we have<br />
π(x) − π √ x +1=φ x, √ x .<br />
One could easily use this idea to compute π(x), the time taking O(x ln ln x)<br />
operations and, if the sieve is segmented, taking O x 1/2 ln x space. (We shall<br />
begin suppressing ln x and ln ln x factors for simplicity, sweeping them under a<br />
rather large rug of O(x ɛ ). It will be clear that each x ɛ could be replaced, with<br />
a little more work, with a small power of logarithm and/or double logarithm.)<br />
A key thought is that the sieve not only allows us to count the primes, it<br />
also identifies them. If it is only the count we are after, then perhaps we can<br />
be speedier.<br />
We shall partition the numbers counted by φ(x, y) by the number of prime<br />
factors they have, counted with multiplicity. Let<br />
φk(x, y) =#{n ≤ x : n has exactly k prime factors, each exceeding y}.<br />
Thus, if x ≥ 1, φ0(x, y) is1,φ1(x, y) is the number of primes in (y, x], φ2(x, y)<br />
is the number of numbers pq ≤ x where p, q areprimeswithy