A152052 cousin primes counts discrepancies

47 views
Skip to first unread message

Jabari Zakiya

unread,
Apr 25, 2026, 10:44:38 PMApr 25
to SeqFan
Hi,

I'm reporting a discrepancy brought to my attention concerning https://oeis.org/A152052.

A152052
Number of cousin primes < 10^n.
2, 9, 41, 203, 1216, 8144, 58622, 440258, 3424680, 27409999, 224373161, 1870585459, 15834656003, 135779962760, 1177207270204

I've created a series of fast|efficient class of residue sieves, based on Modular Groups Zn.
Here's the paper's links explaining the math|code, for SSoZ Twins|Cousins Primes sieves.

Twin Primes Segmented Sieve of Zakiya (SSoZ) Explained
https://www.academia.edu/105821370/Twin_Primes_Segmented_Sieve_of_Zakiya_SSoZ_Explained_Review_Article
https://www.opastpublishers.com/open-access-articles/twin-primes-segmented-sieve-of-zakiya-ssoz-explained.pdf

Below are Rust coded implementations using just ~300loc, including line comments.
They include complete instructions on how to compile and run them, with examples.

Primes
https://gist.github.com/jzakiya/4b04f8ab9f911c6fc91ed616ae6d4281

Twins
https://gist.github.com/jzakiya/b96b0b70cf377dfd8feb3f35eb437225

Cousins
https://gist.github.com/jzakiya/8879c0f4dfda543eaf92a3186de554d7

This table shows the differences between A152052 and my code output.
They differ for 10^1 and 10^2 solely because of counting convention differences.
OEIS counts a cousin pair in range if just the lower prime value is in the range.
So for 10^1 and 10^2, it counts (7, 11) and (97, 101) as pairs in those ranges, while I don't.
I only count pairs to be in a range when both pair primes are in the range.
That's a trivial difference, and for every other range shown there are no split pair primes.

So the count discrepancies starting at 10^8 aren't based on different counting conventions.
This table shows there are no other split cousin pairs for the other ranges.

 Prev Prime   | Range |   Next Prime
                     7 | 10^1  | 11
                  97 | 10^2  | 101
                 997 | 10^3  | 1,009
               9,973 | 10^4  | 10,007
              99,991 | 10^5  | 100,003
             999,983 | 10^6  | 1,000,003
           9,999,991 | 10^7  | 10,000,019
          99,999,989 | 10^8  | 100_000,007
         999,999,937 | 10^9  | 1,000,000,007
       9,999,999,967 | 10^10 | 10,000,000,019
      99,999,999,977 | 10^11 | 100,000,000,003
     999,999,998,989 | 10^12 | 1,000,000,000,039
   9,999,999,999,971 | 10^13 | 10,000,000,000,037
  99,999,999,999,973 | 10^14 | 100,000,000,000,031
 999,999,999,999,989 | 10^15 | 1,000,000,000,000,037

I'm certain the math I do is correct, so I think those counts need to be corrected as shown.
Also notice, my method provides the last cousin (et al) pair values in any range.

https://oeis.org/A152052
A152052
Number of cousin primes < 10^n.
2, 9, 41, 203, 1216, 8144, 58622, 440258, 3424680, 27409999, 224373161, 1870585459, 15834656003, 135779962760, 1177207270204

 Input Range  |   Total Cousins   |      Last Cousin       | OEIS A152052 +|-
--------------|-------------------|------------------------|---------
     10^1     |                 1 |                   7|-4 |   +1
--------------|-------------------|------------------------|---------
     10^2     |                 8 |                  83|-4 |   +1
--------------|-------------------|------------------------|---------
     10^3     |                41 |                 971|-4 |   0
--------------|-------------------|------------------------|---------
     10^4     |               203 |               9,887|-4 |   0
--------------|-------------------|------------------------|---------
     10^5     |             1,216 |              99,881|-4 |   0
--------------|-------------------|------------------------|---------
     10^6     |             8,144 |             999,983|-4 |   0
--------------|-------------------|------------------------|---------
     10^7     |            58,622 |           9,999,401|-4 |   0
--------------|-------------------|------------------------|---------
     10^8     |           440,257 |          99,999,551|-4 |  +1
--------------|-------------------|------------------------|---------
     10^9     |         3,424,679 |         999,999,761|-4 |  +1
--------------|-------------------|------------------------|---------
     10^10    |        27,409,998 |       9,999,999,707|-4 |  +1
--------------|-------------------|------------------------|---------
     10^11    |       224,373,159 |      99,999,999,947|-4 |  +2
--------------|-------------------|------------------------|---------
     10^12    |     1,870,585,457 |     999,999,998,867|-4 |  +2
--------------|-------------------|------------------------|---------
     10^13    |    15,834,656,001 |   9,999,999,999,083|-4 |  +2
--------------|-------------------|------------------------|---------
     10^14    |   135,779,962,758 |  99,999,999,999,467|-4 |  +2
--------------|-------------------|------------------------|---------
     10^15    | 1,177,207,270,202 | 999,999,999,997,841|-4 |  +2
--------------|-------------------|------------------------|---------

To further verify the accuracy of my math|code, I produced the same results
for A007508|Twin Primes, and A006880|Primes, all up to 10^15.

https://oeis.org/A007508
A007508
Number of twin prime pairs below 10^n.
(Formerly M1855)
2, 8, 35, 205, 1224, 8169, 58980, 440312, 3424506, 27412679, 224376048, 1870585220, 15834664872, 135780321665, 1177209242304, 10304195697298, 90948839353159, 808675888577436

 Input Range  |    Total Twins    |       Last Twin        | OEIS A007508 +|-
--------------|-------------------|------------------------|---------
     10^1     |                 2 |                   7|-2 |   0
--------------|-------------------|------------------------|---------
     10^2     |                 8 |                  73|-2 |   0
--------------|-------------------|------------------------|---------
     10^3     |                35 |                 883|-2 |   0
--------------|-------------------|------------------------|---------
     10^4     |               205 |               9,931|-2 |   0
--------------|-------------------|------------------------|---------
     10^5     |             1,224 |              99,991|-2 |   0
--------------|-------------------|------------------------|---------
     10^6     |             8,169 |             999,961|-2 |   0
--------------|-------------------|------------------------|---------
     10^7     |            58,980 |           9,999,973|-2 |   0
--------------|-------------------|------------------------|---------
     10^8     |           440,312 |          99,999,589|-2 |   0
--------------|-------------------|------------------------|---------
     10^9     |         3,424,506 |         999,999,193|-2 |   0
--------------|-------------------|------------------------|---------
     10^10    |        27,412,679 |       9,999,999,703|-2 |   0
--------------|-------------------|------------------------|---------
     10^11    |       224,376,048 |      99,999,999,763|-2 |   0
--------------|-------------------|------------------------|---------
     10^12    |     1,870,585,220 |     999,999,999,961|-2 |   0
--------------|-------------------|------------------------|---------
     10^13    |    15,834,664,872 |   9,999,999,998,491|-2 |   0
--------------|-------------------|------------------------|---------
     10^14    |   135,780,321,665 |  99,999,999,999,973|-2 |   0
--------------|-------------------|------------------------|---------
     10^15    | 1,177,209,242,304 | 999,999,999,997,969|-2 |   0
--------------|-------------------|------------------------|---------

https://oeis.org/A006880
A006880
Number of primes < 10^n.
0, 4, 25, 168, 1229, 9592, 78498, 664579, 5761455, 50847534, 455052511, 4118054813, 37607912018, 346065536839, 3204941750802, 29844570422669, 279238341033925, 2623557157654233, 24739954287740860, 234057667276344607, 2220819602560918840, 21127269486018731928, 201467286689315906290

 Input Range  |    Total Primes    |       Last Prime    | OEIS A006880 +|-
--------------|--------------------|---------------------|---------
     10^1     |                  4 |                   7 |   0
--------------|--------------------|---------------------|---------
     10^2     |                 25 |                  97 |   0
--------------|--------------------|---------------------|---------
     10^3     |                168 |                 997 |   0
--------------|--------------------|---------------------|---------
     10^4     |              1,229 |               9,973 |   0
--------------|--------------------|---------------------|---------
     10^5     |              9,592 |              99,991 |   0
--------------|--------------------|---------------------|---------
     10^6     |             78,498 |             999,983 |   0
--------------|--------------------|---------------------|---------
     10^7     |            664,579 |           9,999,991 |   0
--------------|--------------------|---------------------|---------
     10^8     |          5,761,455 |          99,999,989 |   0
--------------|--------------------|---------------------|---------
     10^9     |         50,847,534 |         999,999,937 |   0
--------------|--------------------|---------------------|---------
     10^10    |        455,052,511 |       9,999,999,967 |   0
--------------|--------------------|---------------------|---------
     10^11    |      4,118,054,813 |      99,999,999,977 |   0
--------------|--------------------|---------------------|---------
     10^12    |     37,607,912,018 |     999,999,998,989 |   0
--------------|--------------------|---------------------|---------
     10^13    |    346,065,536,839 |   9,999,999,999,971 |   0
--------------|--------------------|---------------------|---------
     10^14    |  3,204,941,750,802 |  99,999,999,999,973 |   0
--------------|--------------------|---------------------|---------
     10^15    | 29,844,570,422,669 | 999,999,999,999,989 |   0
--------------|--------------------|---------------------|---------

Below I provide the Rust code output that generated all the primes sieves data shown.
It was compiled with Rust 1.95.0 (latest at time of writing) -- https://rust-lang.org/

Here are my laptop's system specs:
➜  ~ fastfetch
 #############################+           jzakiya@jzakiya
.%#######################%@@@+            ---------------
            .           :#@%-             OS: TUXEDO OS x86_64
           .#@%%%-     =@@#.              Kernel: Linux 6.17.0-113020-tuxedo
             *@%@@=   +@@+                Uptime: 1 day, 15 hours, 50 mins
              =@@%@+.#@%-                 Packages: 3190 (dpkg), 14 (flatpak)
               -@@%@@@#:                  Shell: zsh 5.9
                .#@%%@-                   Display (BOE0A1A): 2560x1440 in 17", 165 Hz [External]
                :#@@%@@=                  DE: KDE Plasma 6.5.2
               =@@+=@@%@+                 WM: KWin (X11)
             .#@@=  -@@%@#                WM Theme: Breeze
            -%@#:    :%@%@%:              Theme: Breeze (TUXEDOLight) [Qt], Breeze [GTK2/3]
           *@@+       .#%%%%-             Icons: tuxedo-breeze-dark [Qt], tuxedo-breeze-dark [GTK2/3/4]
         :%@%-              .             Font: Noto Sans (10pt) [Qt], Noto Sans (10pt) [GTK2/3/4]
        +@@@%#%%%%%%%%%%%%%%%%%%%%%%%.    Cursor: breeze (24px)
       +######################*******     Terminal: konsole 25.8.2
                                          CPU: AMD Ryzen 9 7945HX (32) @ 5.46 GHz
                                          GPU: NVIDIA GeForce RTX 4060 Max-Q / Mobile [Discrete]
                                          Memory: 6.94 GiB / 62.57 GiB (11%)
                                          Swap: Disabled
                                          Disk (/): 187.75 GiB / 915.53 GiB (21%) - ext4
                                          Local IP (wlo1): 10.92.252.160/8
                                          Battery (BAT): 100% [AC Connected]
                                          Locale: en_US.UTF-8

If you get different results running the code please let me know.
This code base is in 6 different compiled languages, which all produce the same results.

Cousin Primes

➜  cousinprimes_ssoz ./target/release/cousinprimes_ssoz195 10
threads = 32
using Prime Generator parameters for P3
segment size = 2 resgroups; seg array is [1 x 1] 64-bits
cousinprime candidates = 2; resgroups = 2
each of 1 threads has nextp[2 x 1] array
setup time = 0.000006493 secs
perform cousinprimes ssoz sieve
1 of 1 cousinpairs done
sieve time = 0.001325442 secs
total time = 0.001337355 secs
last segment = 2 resgroups; segment slices = 1
total cousins = 1; last cousin = 7|-4
➜  cousinprimes_ssoz ./target/release/cousinprimes_ssoz195 100
threads = 32
using Prime Generator parameters for P5
segment size = 4 resgroups; seg array is [1 x 1] 64-bits
cousinprime candidates = 12; resgroups = 4
each of 3 threads has nextp[2 x 1] array
setup time = 0.001394281 secs
perform cousinprimes ssoz sieve
3 of 3 cousinpairs done
sieve time = 0.000047529 secs
total time = 0.001458612 secs
last segment = 4 resgroups; segment slices = 1
total cousins = 8; last cousin = 83|-4
➜  cousinprimes_ssoz ./target/release/cousinprimes_ssoz195 1_000
threads = 32
using Prime Generator parameters for P5
segment size = 34 resgroups; seg array is [1 x 1] 64-bits
cousinprime candidates = 102; resgroups = 34
each of 3 threads has nextp[2 x 8] array
setup time = 0.00139871 secs
perform cousinprimes ssoz sieve
3 of 3 cousinpairs done
sieve time = 0.000050935 secs
total time = 0.001463651 secs
last segment = 34 resgroups; segment slices = 1
total cousins = 41; last cousin = 971|-4
➜  cousinprimes_ssoz ./target/release/cousinprimes_ssoz195 10_000
threads = 32
using Prime Generator parameters for P5
segment size = 334 resgroups; seg array is [1 x 6] 64-bits
cousinprime candidates = 1002; resgroups = 334
each of 3 threads has nextp[2 x 22] array
setup time = 0.001623931 secs
perform cousinprimes ssoz sieve
3 of 3 cousinpairs done
sieve time = 0.000049803 secs
total time = 0.001683312 secs
last segment = 334 resgroups; segment slices = 1
total cousins = 203; last cousin = 9887|-4
➜  cousinprimes_ssoz ./target/release/cousinprimes_ssoz195 100_000
threads = 32
using Prime Generator parameters for P5
segment size = 3334 resgroups; seg array is [1 x 53] 64-bits
cousinprime candidates = 10002; resgroups = 3334
each of 3 threads has nextp[2 x 62] array
setup time = 0.001598644 secs
perform cousinprimes ssoz sieve
3 of 3 cousinpairs done
sieve time = 0.000073378 secs
total time = 0.001679636 secs
last segment = 3334 resgroups; segment slices = 1
total cousins = 1216; last cousin = 99881|-4
➜  cousinprimes_ssoz ./target/release/cousinprimes_ssoz195 1_000_000
threads = 32
using Prime Generator parameters for P5
segment size = 33334 resgroups; seg array is [1 x 521] 64-bits
cousinprime candidates = 100002; resgroups = 33334
each of 3 threads has nextp[2 x 165] array
setup time = 0.001802335 secs
perform cousinprimes ssoz sieve
3 of 3 cousinpairs done
sieve time = 0.000188332 secs
total time = 0.002000036 secs
last segment = 33334 resgroups; segment slices = 1
total cousins = 8144; last cousin = 999983|-4
➜  cousinprimes_ssoz ./target/release/cousinprimes_ssoz195 10_000_000
threads = 32
using Prime Generator parameters for P5
segment size = 163840 resgroups; seg array is [1 x 2560] 64-bits
cousinprime candidates = 1000002; resgroups = 333334
each of 3 threads has nextp[2 x 443] array
setup time = 0.002206131 secs
perform cousinprimes ssoz sieve
3 of 3 cousinpairs done
sieve time = 0.000553386 secs
total time = 0.002770318 secs
last segment = 5654 resgroups; segment slices = 3
total cousins = 58622; last cousin = 9999401|-4
➜  cousinprimes_ssoz ./target/release/cousinprimes_ssoz195 100_000_000
threads = 32
using Prime Generator parameters for P7
segment size = 327680 resgroups; seg array is [1 x 5120] 64-bits
cousinprime candidates = 7142865; resgroups = 476191
each of 15 threads has nextp[2 x 1225] array
setup time = 0.002415353 secs
perform cousinprimes ssoz sieve
15 of 15 cousinpairs done
sieve time = 0.001247636 secs
total time = 0.003671535 secs
last segment = 148511 resgroups; segment slices = 2
total cousins = 440257; last cousin = 99999551|-4
➜  cousinprimes_ssoz ./target/release/cousinprimes_ssoz195 1_000_000_000
threads = 32
using Prime Generator parameters for P7
segment size = 327680 resgroups; seg array is [1 x 5120] 64-bits
cousinprime candidates = 71428575; resgroups = 4761905
each of 15 threads has nextp[2 x 3397] array
setup time = 0.002828877 secs
perform cousinprimes ssoz sieve
15 of 15 cousinpairs done
sieve time = 0.009043025 secs
total time = 0.011880938 secs
last segment = 174385 resgroups; segment slices = 15
total cousins = 3424679; last cousin = 999999761|-4
➜  cousinprimes_ssoz ./target/release/cousinprimes_ssoz195 10_000_000_000
threads = 32
using Prime Generator parameters for P11
segment size = 655360 resgroups; seg array is [1 x 10240] 64-bits
cousinprime candidates = 584415675; resgroups = 4329005
each of 135 threads has nextp[2 x 9587] array
setup time = 0.003768237 secs
perform cousinprimes ssoz sieve
135 of 135 cousinpairs done
sieve time = 0.049233888 secs
total time = 0.053012534 secs
last segment = 396845 resgroups; segment slices = 7
total cousins = 27409998; last cousin = 9999999707|-4
➜  cousinprimes_ssoz ./target/release/cousinprimes_ssoz195 100_000_000_000
threads = 32
using Prime Generator parameters for P13
segment size = 1310720 resgroups; seg array is [1 x 20480] 64-bits
cousinprime candidates = 4945055940; resgroups = 3330004
each of 1485 threads has nextp[2 x 27287] array
setup time = 0.006054608 secs
perform cousinprimes ssoz sieve
1485 of 1485 cousinpairs done
sieve time = 0.39563282 secs
total time = 0.401698569 secs
last segment = 708564 resgroups; segment slices = 3
total cousins = 224373159; last cousin = 99999999947|-4
➜  cousinprimes_ssoz
➜  cousinprimes_ssoz ./target/release/cousinprimes_ssoz195 1_000_000_000_000
threads = 32
using Prime Generator parameters for P13
segment size = 2007040 resgroups; seg array is [1 x 31360] 64-bits
cousinprime candidates = 49450550490; resgroups = 33300034
each of 1485 threads has nextp[2 x 78492] array
setup time = 0.009416754 secs
perform cousinprimes ssoz sieve
1485 of 1485 cousinpairs done
sieve time = 3.981641159 secs
total time = 3.991066789 secs
last segment = 1187394 resgroups; segment slices = 17
total cousins = 1870585457; last cousin = 999999998867|-4
➜  cousinprimes_ssoz ./target/release/cousinprimes_ssoz195 10_000_000_000_000
threads = 32
using Prime Generator parameters for P13
segment size = 3932160 resgroups; seg array is [1 x 61440] 64-bits
cousinprime candidates = 494505495990; resgroups = 333000334
each of 1485 threads has nextp[2 x 227641] array
setup time = 0.016612148 secs
perform cousinprimes ssoz sieve
1485 of 1485 cousinpairs done
sieve time = 49.237868405 secs
total time = 49.254491574 secs
last segment = 2698894 resgroups; segment slices = 85
total cousins = 15834656001; last cousin = 9999999999083|-4
➜  cousinprimes_ssoz ./target/release/cousinprimes_ssoz195 100_000_000_000_000
threads = 32
using Prime Generator parameters for P17
segment size = 3932160 resgroups; seg array is [1 x 61440] 64-bits
cousinprime candidates = 4363283778975; resgroups = 195882549
each of 22275 threads has nextp[2 x 664572] array
setup time = 0.035032744 secs
perform cousinprimes ssoz sieve
22275 of 22275 cousinpairs done
sieve time = 554.496518589 secs
total time = 554.531561423 secs
last segment = 3206709 resgroups; segment slices = 50
total cousins = 135779962758; last cousin = 99999999999467|-4
➜  cousinprimes_ssoz ./target/release/cousinprimes_ssoz195 1_000_000_000_000_000
threads = 32
using Prime Generator parameters for P17
segment size = 3932160 resgroups; seg array is [1 x 61440] 64-bits
cousinprime candidates = 43632837767475; resgroups = 1958825489
each of 22275 threads has nextp[2 x 1951950] array
setup time = 0.072061596 secs
perform cousinprimes ssoz sieve
22275 of 22275 cousinpairs done
sieve time = 13619.680235704 secs
total time = 13619.752305666 secs
last segment = 609809 resgroups; segment slices = 499
total cousins = 1177207270202; last cousin = 999999999997841|-4

Twin Primes

➜  twinprimes_ssoz git:(master) ✗ ./target/release/twinprimes_ssoz195 10
threads = 32
using Prime Generator parameters for P3
segment size = 2 resgroups; seg array is [1 x 1] 64-bits
twinprime candidates = 2; resgroups = 2
each of 1 threads has nextp[2 x 1] array
setup time = 0.000006712 secs
perform twinprimes ssoz sieve
1 of 1 twinpairs done
sieve time = 0.001312358 secs
total time = 0.0013242 secs
last segment = 2 resgroups; segment slices = 1
total twins = 2; last twin = 7|-2
➜  twinprimes_ssoz git:(master) ✗ ./target/release/twinprimes_ssoz195 100
threads = 32
using Prime Generator parameters for P5
segment size = 4 resgroups; seg array is [1 x 1] 64-bits
twinprime candidates = 12; resgroups = 4
each of 3 threads has nextp[2 x 1] array
setup time = 0.001314091 secs
perform twinprimes ssoz sieve
3 of 3 twinpairs done
sieve time = 0.000059602 secs
total time = 0.001382239 secs
last segment = 4 resgroups; segment slices = 1
total twins = 8; last twin = 73|-2
➜  twinprimes_ssoz git:(master) ✗ ./target/release/twinprimes_ssoz195 1_000
threads = 32
using Prime Generator parameters for P5
segment size = 34 resgroups; seg array is [1 x 1] 64-bits
twinprime candidates = 102; resgroups = 34
each of 3 threads has nextp[2 x 8] array
setup time = 0.001395954 secs
perform twinprimes ssoz sieve
3 of 3 twinpairs done
sieve time = 0.000089788 secs
total time = 0.001495891 secs
last segment = 34 resgroups; segment slices = 1
total twins = 35; last twin = 883|-2
➜  twinprimes_ssoz git:(master) ✗ ./target/release/twinprimes_ssoz195 10_000
threads = 32
using Prime Generator parameters for P5
segment size = 334 resgroups; seg array is [1 x 6] 64-bits
twinprime candidates = 1002; resgroups = 334
each of 3 threads has nextp[2 x 22] array
setup time = 0.001577103 secs
perform twinprimes ssoz sieve
3 of 3 twinpairs done
sieve time = 0.000054492 secs
total time = 0.001639269 secs
last segment = 334 resgroups; segment slices = 1
total twins = 205; last twin = 9931|-2
➜  twinprimes_ssoz git:(master) ✗ ./target/release/twinprimes_ssoz195 100_000
threads = 32
using Prime Generator parameters for P5
segment size = 3334 resgroups; seg array is [1 x 53] 64-bits
twinprime candidates = 10002; resgroups = 3334
each of 3 threads has nextp[2 x 62] array
setup time = 0.001665458 secs
perform twinprimes ssoz sieve
3 of 3 twinpairs done
sieve time = 0.000050104 secs
total time = 0.001724349 secs
last segment = 3334 resgroups; segment slices = 1
total twins = 1224; last twin = 99991|-2
➜  twinprimes_ssoz git:(master) ✗ ./target/release/twinprimes_ssoz195 1_000_000
threads = 32
using Prime Generator parameters for P5
segment size = 33334 resgroups; seg array is [1 x 521] 64-bits
twinprime candidates = 100002; resgroups = 33334
each of 3 threads has nextp[2 x 165] array
setup time = 0.00202392 secs
perform twinprimes ssoz sieve
3 of 3 twinpairs done
sieve time = 0.000101991 secs
total time = 0.002132924 secs
last segment = 33334 resgroups; segment slices = 1
total twins = 8169; last twin = 999961|-2
➜  twinprimes_ssoz git:(master) ✗ ./target/release/twinprimes_ssoz195 10_000_000
threads = 32
using Prime Generator parameters for P5
segment size = 163840 resgroups; seg array is [1 x 2560] 64-bits
twinprime candidates = 1000002; resgroups = 333334
each of 3 threads has nextp[2 x 443] array
setup time = 0.002313302 secs
perform twinprimes ssoz sieve
3 of 3 twinpairs done
sieve time = 0.000524852 secs
total time = 0.002847482 secs
last segment = 5654 resgroups; segment slices = 3
total twins = 58980; last twin = 9999973|-2
➜  twinprimes_ssoz git:(master) ✗ ./target/release/twinprimes_ssoz195 100_000_000
threads = 32
using Prime Generator parameters for P7
segment size = 327680 resgroups; seg array is [1 x 5120] 64-bits
twinprime candidates = 7142865; resgroups = 476191
each of 15 threads has nextp[2 x 1225] array
setup time = 0.002575162 secs
perform twinprimes ssoz sieve
15 of 15 twinpairs done
sieve time = 0.001363193 secs
total time = 0.003952802 secs
last segment = 148511 resgroups; segment slices = 2
total twins = 440312; last twin = 99999589|-2
➜  twinprimes_ssoz git:(master) ✗ ./target/release/twinprimes_ssoz195 1_000_000_000
threads = 32
using Prime Generator parameters for P7
segment size = 327680 resgroups; seg array is [1 x 5120] 64-bits
twinprime candidates = 71428575; resgroups = 4761905
each of 15 threads has nextp[2 x 3397] array
setup time = 0.002963119 secs
perform twinprimes ssoz sieve
15 of 15 twinpairs done
sieve time = 0.010341837 secs
total time = 0.013314393 secs
last segment = 174385 resgroups; segment slices = 15
total twins = 3424506; last twin = 999999193|-2
➜  twinprimes_ssoz git:(master) ✗ ./target/release/twinprimes_ssoz195 10_000_000_000
threads = 32
using Prime Generator parameters for P11
segment size = 655360 resgroups; seg array is [1 x 10240] 64-bits
twinprime candidates = 584415675; resgroups = 4329005
each of 135 threads has nextp[2 x 9587] array
setup time = 0.004155252 secs
perform twinprimes ssoz sieve
135 of 135 twinpairs done
sieve time = 0.048757115 secs
total time = 0.05292485 secs
last segment = 396845 resgroups; segment slices = 7
total twins = 27412679; last twin = 9999999703|-2
➜  twinprimes_ssoz git:(master) ✗ ./target/release/twinprimes_ssoz195 100_000_000_000
threads = 32
using Prime Generator parameters for P13
segment size = 1310720 resgroups; seg array is [1 x 20480] 64-bits
twinprime candidates = 4945055940; resgroups = 3330004
each of 1485 threads has nextp[2 x 27287] array
setup time = 0.006115793 secs
perform twinprimes ssoz sieve
1485 of 1485 twinpairs done
sieve time = 0.396490636 secs
total time = 0.402613833 secs
last segment = 708564 resgroups; segment slices = 3
total twins = 224376048; last twin = 99999999763|-2
➜  twinprimes_ssoz git:(master) ✗ ./target/release/twinprimes_ssoz195 1_000_000_000_000
threads = 32
using Prime Generator parameters for P13
segment size = 2007040 resgroups; seg array is [1 x 31360] 64-bits
twinprime candidates = 49450550490; resgroups = 33300034
each of 1485 threads has nextp[2 x 78492] array
setup time = 0.009572967 secs
perform twinprimes ssoz sieve
1485 of 1485 twinpairs done
sieve time = 3.951451955 secs
total time = 3.9610411819999998 secs
last segment = 1187394 resgroups; segment slices = 17
total twins = 1870585220; last twin = 999999999961|-2
➜  twinprimes_ssoz git:(master) ✗ ./target/release/twinprimes_ssoz195 10_000_000_000_000
threads = 32
using Prime Generator parameters for P13
segment size = 3932160 resgroups; seg array is [1 x 61440] 64-bits
twinprime candidates = 494505495990; resgroups = 333000334
each of 1485 threads has nextp[2 x 227641] array
setup time = 0.015420767 secs
perform twinprimes ssoz sieve
1485 of 1485 twinpairs done
sieve time = 49.562678348 secs
total time = 49.578113703 secs
last segment = 2698894 resgroups; segment slices = 85
total twins = 15834664872; last twin = 9999999998491|-2
➜  twinprimes_ssoz git:(master) ✗ ./target/release/twinprimes_ssoz195 100_000_000_000_000
threads = 32
using Prime Generator parameters for P17
segment size = 3932160 resgroups; seg array is [1 x 61440] 64-bits
twinprime candidates = 4363283778975; resgroups = 195882549
each of 22275 threads has nextp[2 x 664572] array
setup time = 0.037283438 secs
perform twinprimes ssoz sieve
22275 of 22275 twinpairs done
sieve time = 551.984738709 secs
total time = 552.022031043 secs
last segment = 3206709 resgroups; segment slices = 50
total twins = 135780321665; last twin = 99999999999973|-2
➜  twinprimes_ssoz git:(master) ✗ ./target/release/twinprimes_ssoz195 1_000_000_000_000_000
threads = 32
using Prime Generator parameters for P17
segment size = 3932160 resgroups; seg array is [1 x 61440] 64-bits
twinprime candidates = 43632837767475; resgroups = 1958825489
each of 22275 threads has nextp[2 x 1951950] array
setup time = 0.072185198 secs
perform twinprimes ssoz sieve
22275 of 22275 twinpairs done
sieve time = 13673.930941563 secs
total time = 13674.003161366 secs
last segment = 609809 resgroups; segment slices = 499
total twins = 1177209242304; last twin = 999999999997969|-2

Primes

➜  primes_ssoz git:(master) ✗ ./target/release/primes_ssoz195 10
threads = 32
using Prime Generator parameters for P3
segment size = 2 resgroups; seg array is [1 x 1] 64-bits
prime candidates = 4; resgroups = 2
each of 2 threads has nextp[1 x 1] array
setup time = 0.000006752 secs
perform primes ssoz sieve
2 of 2 residues done
sieve time = 0.001361148 secs
total time = 0.001377319 secs
last segment = 2 resgroups; segment slices = 1
total primes = 4; last prime = 7
➜  primes_ssoz git:(master) ✗ ./target/release/primes_ssoz195 100
threads = 32
using Prime Generator parameters for P5
segment size = 4 resgroups; seg array is [1 x 1] 64-bits
prime candidates = 32; resgroups = 4
each of 8 threads has nextp[1 x 1] array
setup time = 0.001392297 secs
perform primes ssoz sieve
8 of 8 residues done
sieve time = 0.000117951 secs
total time = 0.001522411 secs
last segment = 4 resgroups; segment slices = 1
total primes = 25; last prime = 97
➜  primes_ssoz git:(master) ✗ ./target/release/primes_ssoz195 1_000
threads = 32
using Prime Generator parameters for P5
segment size = 34 resgroups; seg array is [1 x 1] 64-bits
prime candidates = 272; resgroups = 34
each of 8 threads has nextp[1 x 8] array
setup time = 0.001300405 secs
perform primes ssoz sieve
8 of 8 residues done
sieve time = 0.000178064 secs
total time = 0.001485722 secs
last segment = 34 resgroups; segment slices = 1
total primes = 168; last prime = 997
➜  primes_ssoz git:(master) ✗ ./target/release/primes_ssoz195 10_000
threads = 32
using Prime Generator parameters for P5
segment size = 334 resgroups; seg array is [1 x 6] 64-bits
prime candidates = 2672; resgroups = 334
each of 8 threads has nextp[1 x 22] array
setup time = 0.001524865 secs
perform primes ssoz sieve
8 of 8 residues done
sieve time = 0.000080451 secs
total time = 0.001613601 secs
last segment = 334 resgroups; segment slices = 1
total primes = 1229; last prime = 9973
➜  primes_ssoz git:(master) ✗ ./target/release/primes_ssoz195 100_000
threads = 32
using Prime Generator parameters for P5
segment size = 3334 resgroups; seg array is [1 x 53] 64-bits
prime candidates = 26672; resgroups = 3334
each of 8 threads has nextp[1 x 62] array
setup time = 0.001766618 secs
perform primes ssoz sieve
8 of 8 residues done
sieve time = 0.000124974 secs
total time = 0.001900619 secs
last segment = 3334 resgroups; segment slices = 1
total primes = 9592; last prime = 99991
➜  primes_ssoz git:(master) ✗ ./target/release/primes_ssoz195 1_000_000
threads = 32
using Prime Generator parameters for P5
segment size = 33334 resgroups; seg array is [1 x 521] 64-bits
prime candidates = 266672; resgroups = 33334
each of 8 threads has nextp[1 x 165] array
setup time = 0.001768401 secs
perform primes ssoz sieve
8 of 8 residues done
sieve time = 0.000133039 secs
total time = 0.001910257 secs
last segment = 33334 resgroups; segment slices = 1
total primes = 78498; last prime = 999983
➜  primes_ssoz git:(master) ✗ ./target/release/primes_ssoz195 10_000_000
threads = 32
using Prime Generator parameters for P5
segment size = 163840 resgroups; seg array is [1 x 2560] 64-bits
prime candidates = 2666672; resgroups = 333334
each of 8 threads has nextp[1 x 443] array
setup time = 0.002297352 secs
perform primes ssoz sieve
8 of 8 residues done
sieve time = 0.000325319 secs
total time = 0.0026327 secs
last segment = 5654 resgroups; segment slices = 3
total primes = 664579; last prime = 9999991
➜  primes_ssoz git:(master) ✗ ./target/release/primes_ssoz195 100_000_000
threads = 32
using Prime Generator parameters for P7
segment size = 327680 resgroups; seg array is [1 x 5120] 64-bits
prime candidates = 22857168; resgroups = 476191
each of 48 threads has nextp[1 x 1225] array
setup time = 0.002746102 secs
perform primes ssoz sieve
48 of 48 residues done
sieve time = 0.001205818 secs
total time = 0.003965806 secs
last segment = 148511 resgroups; segment slices = 2
total primes = 5761455; last prime = 99999989
➜  primes_ssoz git:(master) ✗ ./target/release/primes_ssoz195 1_000_000_000
threads = 32
using Prime Generator parameters for P7
segment size = 327680 resgroups; seg array is [1 x 5120] 64-bits
prime candidates = 228571440; resgroups = 4761905
each of 48 threads has nextp[1 x 3397] array
setup time = 0.003205052 secs
perform primes ssoz sieve
48 of 48 residues done
sieve time = 0.010842535 secs
total time = 0.014057114 secs
last segment = 174385 resgroups; segment slices = 15
total primes = 50847534; last prime = 999999937
➜  primes_ssoz git:(master) ✗ ./target/release/primes_ssoz195 10_000_000_000
threads = 32
using Prime Generator parameters for P11
segment size = 655360 resgroups; seg array is [1 x 10240] 64-bits
prime candidates = 2077922400; resgroups = 4329005
each of 480 threads has nextp[1 x 9587] array
setup time = 0.004288341 secs
perform primes ssoz sieve
480 of 480 residues done
sieve time = 0.080146456 secs
total time = 0.084443753 secs
last segment = 396845 resgroups; segment slices = 7
total primes = 455052511; last prime = 9999999967
➜  primes_ssoz git:(master) ✗ ./target/release/primes_ssoz195 100_000_000_000
threads = 32
using Prime Generator parameters for P13
segment size = 1310720 resgroups; seg array is [1 x 20480] 64-bits
prime candidates = 19180823040; resgroups = 3330004
each of 5760 threads has nextp[1 x 27287] array
setup time = 0.006155096 secs
perform primes ssoz sieve
5760 of 5760 residues done
sieve time = 0.757104718 secs
total time = 0.763270023 secs
last segment = 708564 resgroups; segment slices = 3
total primes = 4118054813; last prime = 99999999977
➜  primes_ssoz git:(master) ✗ ./target/release/primes_ssoz195 1_000_000_000_000
threads = 32
using Prime Generator parameters for P13
segment size = 2007040 resgroups; seg array is [1 x 31360] 64-bits
prime candidates = 191808195840; resgroups = 33300034
each of 5760 threads has nextp[1 x 78492] array
setup time = 0.009670139 secs
perform primes ssoz sieve
5760 of 5760 residues done
sieve time = 7.843992109 secs
total time = 7.853673529 secs
last segment = 1187394 resgroups; segment slices = 17
total primes = 37607912018; last prime = 999999999989
➜  primes_ssoz git:(master) ✗ ./target/release/primes_ssoz195 10_000_000_000_000
threads = 32
using Prime Generator parameters for P13
segment size = 3932160 resgroups; seg array is [1 x 61440] 64-bits
prime candidates = 1918081923840; resgroups = 333000334
each of 5760 threads has nextp[1 x 227641] array
setup time = 0.017074735 secs
perform primes ssoz sieve
5760 of 5760 residues done
sieve time = 97.204540932 secs
total time = 97.221627038 secs
last segment = 2698894 resgroups; segment slices = 85
total primes = 346065536839; last prime = 9999999999971
➜  primes_ssoz git:(master) ✗ ./target/release/primes_ssoz195 100_000_000_000_000
threads = 32
using Prime Generator parameters for P13
segment size = 3932160 resgroups; seg array is [1 x 61440] 64-bits
prime candidates = 19180819186560; resgroups = 3330003331
each of 5760 threads has nextp[1 x 664573] array
setup time = 0.030882963 secs
perform primes ssoz sieve
5760 of 5760 residues done
sieve time = 1204.126359644 secs
total time = 1204.157252085 secs
last segment = 3395971 resgroups; segment slices = 847
total primes = 3204941750802; last prime = 99999999999973
➜  primes_ssoz git:(master) ✗ ./target/release/primes_ssoz195 1_000_000_000_000_000
threads = 32
using Prime Generator parameters for P17
segment size = 3932160 resgroups; seg array is [1 x 61440] 64-bits
prime candidates = 180525357066240; resgroups = 1958825489
each of 92160 threads has nextp[1 x 1951950] array
setup time = 0.074149576 secs
perform primes ssoz sieve
92160 of 92160 residues done
sieve time = 29739.763633422 secs
total time = 29739.837793658 secs
last segment = 609809 resgroups; segment slices = 499
total primes = 29844570422669; last prime = 999999999999989

Allan Wechsler

unread,
Apr 25, 2026, 11:02:50 PMApr 25
to seq...@googlegroups.com
I don't see the difficulty. A152052 states its own convention clearly and adheres to it. Your work is a useful confirmation of the given data. Are you proposing that both the definition and the date be changed?

This sort of thing comes up a lot, where slight differences in the definition affect the first couple of entries of a sequence, and thereafter have no effect. Rather than archive multiple different versions, OEIS tends to pick one. The help pages recommend, in the case of a search with no matches, dropping the first couple of entries and retrying, in case of exactly such minor variations. Any researcher following this advice would find A152052 regardless of which convention they were using.

I would favor a comment saying something like "Requiring both cousins to be under the limit changes only A(1) and A(2), reducing each by 2. There may be other discrepancies for N > 15." But I'm not convinced any other action is warranted.

-- Allan

--
You received this message because you are subscribed to the Google Groups "SeqFan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to seqfan+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/seqfan/5f355b03-1016-40d5-8f98-20992ab66eb5n%40googlegroups.com.

Jabari Zakiya

unread,
Apr 25, 2026, 11:15:41 PMApr 25
to SeqFan
What I'm saying is the OEIS counts for the ranges 10^8 -- 10^15 are off by the amounts I show in the tables, i.e. mine are correct.
Since OEIS doesn't stated how it derived its counts I couldn't check its method on my system.

Allan Wechsler

unread,
Apr 25, 2026, 11:32:03 PMApr 25
to seq...@googlegroups.com
I misunderstood Jabari, who is (I now think) agnostic on A(1) and A(2), but is dubious about the data for N >= 8. This can only be settled by numerical confirmation from others. If the given data are wrong they should certainly be corrected. I apologize for my misunderstanding.

-- Allan

Sean A. Irvine

unread,
Apr 25, 2026, 11:58:33 PMApr 25
to seq...@googlegroups.com
I compute A15052(8) = 440258, so at least for n=8, I agree with the existing value.

Sean.


D. S. McNeil

unread,
Apr 25, 2026, 11:59:01 PMApr 25
to seq...@googlegroups.com
I think the bug is in the new code; a quick brute force check gives me 440258 and 3424680, matching the OEIS sequence, as expected.  For example:

In [1]: from sympy import primerange
In [2]: P=set(primerange(2,10**8+1))
In [3]: len(P)
Out[3]: 5761455
In [4]: sum((p+4 in P) for p in P)
Out[4]: 440258

Haven't looked too deeply into it, but it seems to me like when the Rust code switches to a wheel , any small prime is no longer represented in the sieve’s residue classes. As a result, cousin pairs whose lower element is such a prime (e.g. for , for ) are not counted by the main sieve.  The implementation compensates only for , so once is used it undercounts by 1, and once is used it undercounts by 2, which matches the scale the errors are introduced.

I'm only about 84% confident of that theory, although it seems to match the data, but I'm sure for at least the lower values where there's a difference, it's the OEIS which is right.


Doug


Jabari Zakiya

unread,
Apr 26, 2026, 1:53:19 PMApr 26
to SeqFan
The residues sieve is correct. The problem was a count initiation error in my code.
It's now fixed, and I now get the same results as A152052.
Here's the updated|corrected Rust code version: 

It would've been nice to have a reference implementation to check results against.
I used primesieve -- https://github.com/kimwalisch/primesieve -- to check my twins and primes results against, but it doesn't do cousin primes.

I'm interested, though, in seeing performance comparisons between whatever OEIS uses and my code.
Can the source code be provided I can run  tests against? 

Tom Duff

unread,
Apr 26, 2026, 6:46:39 PMApr 26
to seq...@googlegroups.com
All OEIS content is provided by volunteers and vetted by volunteer editors. If a sequence page has no program it's because no one ever submitted one.

Jabari Zakiya

unread,
Apr 26, 2026, 10:03:51 PMApr 26
to seq...@googlegroups.com
I offer my code as a reference version for cousin primes if people want.
Feel free to kick all the tires, and stress test it to your heart's content.
I would urge you first to study|understand the paper on it.
The underlying math is the fastest, and most efficient, way to generate|count cousin primes.
I'm always available to answer any questions too.

--
You received this message because you are subscribed to the Google Groups "SeqFan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to seqfan+un...@googlegroups.com.

Daniel Mondot

unread,
Apr 27, 2026, 12:19:48 PMApr 27
to seq...@googlegroups.com
For what it's worth, I can confirm the first 11 terms (2, 9, 41, 203, 1216, 8144, 58622, 440258, 3424680, 27409999, 224373161) 
Computer time : 35 minutes

Daniel.

Reply all
Reply to author
Forward
0 new messages