line |
true |
false |
branch |
85
|
7 |
1273 |
if (n <= 2) return (n==0) ? 0 : (n==1) ? 2 : 11; |
|
7 |
0 |
if (n <= 2) return (n==0) ? 0 : (n==1) ? 2 : 11; |
|
1 |
6 |
if (n <= 2) return (n==0) ? 0 : (n==1) ? 2 : 11; |
88
|
1273 |
0 |
if (n < UVCONST(2256197512) || BITS_PER_WORD < 64) { |
93
|
226 |
1047 |
if (n < 20) mult = 3580; |
94
|
931 |
116 |
else if (n < 98) mult = 3340; |
95
|
12 |
104 |
else if (n < 1580) mult = 3040; |
96
|
1 |
103 |
else if (n < 3242) mult = 2885; |
98
|
5729 |
0 |
for (i = 0; i < SMALL_NRAM_UPPER; i++) |
99
|
103 |
5626 |
if (small_ram_upper_idx[i] > n) |
103
|
0 |
1273 |
if (res > (UV_MAX/mult)) res = (UV) (((long double) mult / 4096.0L) * res); |
107
|
0 |
0 |
for (i = 0; i < LARGE_NRAM_UPPER; i++) |
108
|
0 |
0 |
if (large_ram_upper_idx[i] > n) |
111
|
0 |
0 |
if (res > (UV_MAX/mult)) res = (UV) (((long double) mult / 16384.0L) * res); |
115
|
628 |
645 |
if (n > 43 && n < 10000) { |
|
526 |
102 |
if (n > 43 && n < 10000) { |
120
|
24 |
502 |
if (ps < res) |
171
|
7 |
1288 |
if (n <= 2) return (n==0) ? 0 : (n==1) ? 2 : 11; |
|
7 |
0 |
if (n <= 2) return (n==0) ? 0 : (n==1) ? 2 : 11; |
|
1 |
6 |
if (n <= 2) return (n==0) ? 0 : (n==1) ? 2 : 11; |
175
|
1288 |
0 |
if (n < UVCONST(2267483962) || BITS_PER_WORD < 64) { |
176
|
3201 |
0 |
for (i = 0; i < SMALL_NRAM_LOWER; i++) |
177
|
1288 |
1913 |
if (small_ram_lower_idx[i] > n) |
180
|
0 |
1288 |
if (res > (UV_MAX/mult)) res = (UV) (((long double) mult / 512.0L) * res); |
184
|
0 |
0 |
if (n < large_ram_lower_idx[LARGE_NRAM_LOWER-1]) { |
185
|
0 |
0 |
for (i = 0; i < LARGE_NRAM_LOWER; i++) |
186
|
0 |
0 |
if (large_ram_lower_idx[i] > n) |
189
|
0 |
0 |
if (res > (UV_MAX/mult)) res = (UV) (((long double) mult / 4096.0L) * res); |
204
|
18 |
233 |
if (n < 29) return (n < 2) ? 0 : (n < 11) ? 1 : (n < 17) ? 2 : 3; |
|
18 |
0 |
if (n < 29) return (n < 2) ? 0 : (n < 11) ? 1 : (n < 17) ? 2 : 3; |
|
11 |
7 |
if (n < 29) return (n < 2) ? 0 : (n < 11) ? 1 : (n < 17) ? 2 : 3; |
|
7 |
4 |
if (n < 29) return (n < 2) ? 0 : (n < 11) ? 1 : (n < 17) ? 2 : 3; |
209
|
925 |
233 |
while (lo < hi) { |
211
|
449 |
476 |
if (nth_ramanujan_prime_upper(mid) < n) lo = mid+1; |
219
|
16 |
235 |
if (n < 29) return (n < 2) ? 0 : (n < 11) ? 1 : (n < 17) ? 2 : 3; |
|
16 |
0 |
if (n < 29) return (n < 2) ? 0 : (n < 11) ? 1 : (n < 17) ? 2 : 3; |
|
15 |
1 |
if (n < 29) return (n < 2) ? 0 : (n < 11) ? 1 : (n < 17) ? 2 : 3; |
|
7 |
8 |
if (n < 29) return (n < 2) ? 0 : (n < 11) ? 1 : (n < 17) ? 2 : 3; |
224
|
948 |
235 |
while (lo < hi) { |
226
|
587 |
361 |
if (nth_ramanujan_prime_lower(mid) < n) lo = mid+1; |
237
|
0 |
8 |
if (_XS_get_verbose() >= 2) { printf("sieving to %"UVuf" for first %"UVuf" Ramanujan primes\n", max, n); fflush(stdout); } |
238
|
0 |
8 |
Newz(0, L, n, UV); |
241
|
876 |
8 |
for (s = 0, k = 7; k <= max; k += 2) { |
242
|
312 |
564 |
if (is_prime_in_sieve(sieve, k)) s++; |
243
|
771 |
105 |
if (s < n) L[s] = k+1; |
244
|
435 |
441 |
if ((k & 3) == 1 && is_prime_in_sieve(sieve, (k+1)>>1)) s--; |
|
164 |
271 |
if ((k & 3) == 1 && is_prime_in_sieve(sieve, (k+1)>>1)) s--; |
245
|
772 |
104 |
if (s < n) L[s] = k+2; |
255
|
0 |
259 |
if (nlo == 0) nlo = 1; |
256
|
0 |
259 |
if (nhi == 0) nhi = 1; |
259
|
8 |
251 |
if (nlo == 1) return n_ramanujan_primes(nhi); |
261
|
0 |
251 |
Newz(0, L, nhi-nlo+1, UV); |
262
|
0 |
251 |
if (nlo <= 1 && nhi >= 1) L[1-nlo] = 2; |
|
0 |
0 |
if (nlo <= 1 && nhi >= 1) L[1-nlo] = 2; |
263
|
6 |
245 |
if (nlo <= 2 && nhi >= 2) L[2-nlo] = 11; |
|
6 |
0 |
if (nlo <= 2 && nhi >= 2) L[2-nlo] = 11; |
264
|
1 |
250 |
if (nhi < 3) return L; |
269
|
11 |
239 |
if (mink < 15) mink = 15; |
270
|
121 |
129 |
if (mink % 2 == 0) mink--; |
271
|
0 |
250 |
if (verbose >= 2) { printf("Rn[%"UVuf"] to Rn[%"UVuf"] Noe's: %"UVuf" to %"UVuf"\n", nlo, nhi, mink, maxk); fflush(stdout); } |
278
|
250 |
250 |
while (next_segment_primes(ctx, &seg_base, &seg_low, &seg_high)) { |
282
|
250 |
0 |
if (new_size > seg2size) { |
283
|
0 |
250 |
if (seg2size > 0) Safefree(seg2); |
288
|
197201 |
250 |
for (k = seg_low; k <= seg_high; k += 2) { |
289
|
26239 |
170962 |
if (is_prime_in_sieve(segment, k-seg_base)) s++; |
290
|
40729 |
156472 |
if (s >= nlo && s <= nhi) L[s-nlo] = k+1; |
|
14657 |
26072 |
if (s >= nlo && s <= nhi) L[s-nlo] = k+1; |
291
|
98594 |
98607 |
if ((k & 3) == 1 && is_prime_in_sieve(seg2, ((k+1)>>1)-seg2beg)) s--; |
|
13762 |
84832 |
if ((k & 3) == 1 && is_prime_in_sieve(seg2, ((k+1)>>1)-seg2beg)) s--; |
292
|
40459 |
156742 |
if (s >= nlo && s <= nhi) L[s-nlo] = k+2; |
|
14683 |
25776 |
if (s >= nlo && s <= nhi) L[s-nlo] = k+2; |
298
|
0 |
250 |
if (verbose >= 2) { printf("Generated %"UVuf" Ramanujan primes from %"UVuf" to %"UVuf"\n", nhi-nlo+1, L[0], L[nhi-nlo]); fflush(stdout); } |
304
|
2 |
73 |
if (n <= 2) return (n == 0) ? 0 : (n == 1) ? 2 : 11; |
|
2 |
0 |
if (n <= 2) return (n == 0) ? 0 : (n == 1) ? 2 : 11; |
|
1 |
1 |
if (n <= 2) return (n == 0) ? 0 : (n == 1) ? 2 : 11; |
316
|
175 |
0 |
if (high < 2 || high < low) return 0; |
|
0 |
175 |
if (high < 2 || high < low) return 0; |
317
|
0 |
175 |
if (low < 2) low = 2; |
324
|
514 |
175 |
for (lo = 0, hi = nhi-nlo+1; lo < hi; ) { |
326
|
240 |
274 |
if (L[mid] < low) lo = mid+1; |
331
|
373 |
175 |
for (hi = nhi-nlo+1; lo < hi; ) { |
333
|
88 |
285 |
if (L[mid] <= high) lo = mid+1; |
343
|
818 |
166 |
if (!is_prime(n)) return 0; |
344
|
6 |
160 |
if (n < 17) return (n == 2 || n == 11); |
|
5 |
1 |
if (n < 17) return (n == 2 || n == 11); |
|
1 |
4 |
if (n < 17) return (n == 2 || n == 11); |
356
|
0 |
2 |
if (n < 29) return (n < 2) ? 0 : (n < 11) ? 1 : (n < 17) ? 2 : 3; |
|
0 |
0 |
if (n < 29) return (n < 2) ? 0 : (n < 11) ? 1 : (n < 17) ? 2 : 3; |
|
0 |
0 |
if (n < 29) return (n < 2) ? 0 : (n < 11) ? 1 : (n < 17) ? 2 : 3; |
|
0 |
0 |
if (n < 29) return (n < 2) ? 0 : (n < 11) ? 1 : (n < 17) ? 2 : 3; |
359
|
21 |
2 |
while (lo < hi) { |
361
|
7 |
14 |
if (nth_ramanujan_prime_approx(mid) < n) lo = mid+1; |
371
|
23 |
0 |
double weight = (n <= UVCONST(4294967295)) ? 1.62 : 1.51; |
398
|
12 |
0 |
UV i, v, rn, *L, window, swin, ewin, wlen, log2 = log2floor(n), winmult = 1; |
400
|
0 |
12 |
if (n <= 10) return (n < 2) ? 0 : 1; |
403
|
1 |
11 |
if ((n & (n-1)) == 0 && log2 <= RAMPC2) |
|
1 |
0 |
if ((n & (n-1)) == 0 && log2 <= RAMPC2) |
406
|
0 |
11 |
if (_XS_get_verbose()) { printf("ramanujan_prime_count calculating Pi(%lu)\n",n); fflush(stdout); } |
410
|
0 |
11 |
if (n > 1000000000U) winmult = 16; |
414
|
9 |
2 |
swin = (v <= window) ? 1 : v-window; |
418
|
11 |
0 |
if (L[0] < n && L[wlen-1] > n) { |
|
11 |
0 |
if (L[0] < n && L[wlen-1] > n) { |
420
|
191 |
0 |
for (i = 1; i < wlen; i++) |
421
|
11 |
180 |
if (L[i] > n && L[i-1] <= n) |
|
11 |
0 |
if (L[i] > n && L[i-1] <= n) |
423
|
11 |
0 |
if (i < wlen) break; |
426
|
0 |
0 |
if (_XS_get_verbose()) { printf(" ramanujan_prime_count increasing window\n"); fflush(stdout); } |
437
|
10 |
0 |
if (hi < 2 || hi < lo) return 0; |
|
0 |
10 |
if (hi < 2 || hi < lo) return 0; |
441
|
2 |
8 |
if (lo > 2) |