sieve_cluster.pl 4.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #!/usr/bin/perl
  2. # Primes p such that 8 consecutive primes starting with p are {1,2,3,4,5,6,7,8} modulo 13.
  3. # https://oeis.org/A338394
  4. use 5.014;
  5. use ntheory qw(:all);
  6. use experimental qw(signatures);
  7. # New terms found:
  8. # 761457812389, 1079253721703, 1348188886799, 1606702635149, 1824535827869, 2084867892589, 2112142435703, 2838797014093, 3025107969053, 3556206499249, 4117239042619, 4130461496851, 4357514052503, 4836054169103, 4908946925273, 14161747729169, 14247819770939, 18866578471547, 22427393658073, 22835274705283, 27305880660449, 31675129703309, 35265377552159, 36951194202599, 39839235929663, 40583190994529, 42372979438739, 42923079229213, 43554899867519, 43628325363299, 43896197331299, 45749347176209, 49965317538449, 52780474235243, 53195202089069, 55484434190849, 58217172986129, 58548625620239, 60628028874089, 60981093008239, 61230871946999, 61508898520109, 61782463362569, 62260651274849, 65552962831019, 67405791008219, 67754204383529, 68426419393099, 71197879421423, 71481160182979, 77202688959059, 78198493331999, 78866151125789, 81240600887759, 93595283908439, 99680785749299
  9. # Also in the sequence with {1..9} modulo 13:
  10. # 1824535827869
  11. # 14161747729169
  12. # 60628028874089
  13. # 67754204383529
  14. # 81240600887759
  15. # 93595283908439
  16. sub isok ($p) {
  17. for (my $count = 1 ; $count <= 8 ; ++$count) {
  18. $p % 13 == $count or return;
  19. $p = next_prime($p);
  20. }
  21. return 1;
  22. }
  23. foreach my $p (
  24. 5129602609, 40602028559, 69528307577, 129007460609, 236659873633, 322320688171, 371170549153, 390581208473, 441568239503, 651686524243, 761457812389, 807722926973, 855088513163, 855969933859, 977398008289, 1034360135849, 1079253721703, 1348188886799, 1606702635149, 1824535827869, 2084867892589, 2112142435703, 2838797014093, 3025107969053, 3556206499249, 4117239042619, 4130461496851, 4357514052503, 4836054169103, 4908946925273, 18866578471547, 22427393658073, 22835274705283, 31675129703309, 39839235929663, 40583190994529, 42923079229213, 45749347176209, 52780474235243, 58217172986129, 60628028874089, 60981093008239, 68426419393099, 71197879421423, 71481160182979, 81240600887759, 93595283908439,
  25. 1824535827869, 14161747729169, 14247819770939, 27305880660449, 35265377552159, 36951194202599, 42372979438739, 43554899867519, 43628325363299, 43896197331299, 49965317538449, 53195202089069, 55484434190849, 58548625620239, 60628028874089, 61230871946999, 61508898520109, 61782463362569, 62260651274849, 65552962831019, 67405791008219, 67754204383529, 77202688959059, 78198493331999, 78866151125789, 81240600887759, 93595283908439, 99680785749299
  26. ) {
  27. isok($p) || die "error for $p";
  28. }
  29. my %seen;
  30. foreach my $diff (
  31. [40, 54, 94, 160, 174, 214, 228, 234],
  32. [40, 54, 94, 108, 148, 214, 228, 234],
  33. [14, 54, 68, 134, 174, 240, 254, 260],
  34. [14, 54, 68, 108, 174, 188, 254, 266],
  35. [40, 54, 94, 108, 174, 214, 228, 328],
  36. [40, 54, 94, 108, 148, 162, 202, 240],
  37. [14, 54, 68, 108, 122, 188, 228, 284],
  38. [66, 80, 120, 134, 174, 188, 254, 260],
  39. #~ [40, 54, 94, 108, 148, 214, 228, 250],
  40. #~ [14, 54, 68, 108, 122, 162, 228, 330],
  41. #~ [14, 80, 120, 186, 200, 240, 254, 266],
  42. #~ [14, 54, 68, 108, 122, 240, 254, 258],
  43. #~ [40, 54, 94, 108, 148, 214, 228, 276],
  44. #~ [118, 132, 172, 186, 226, 292, 306, 340],
  45. #~ [40, 54, 94, 108, 148, 214, 228, 244],
  46. #~ [14, 54, 68, 186, 200, 240, 254, 276],
  47. #~ [14, 54, 68, 186, 200, 240, 306, 314],
  48. #~ [40, 54, 94, 160, 174, 214, 228, 234],
  49. ) {
  50. pop @$diff;
  51. next if $seen{join(' ', @$diff)}++;
  52. say ":: Testing with differences (@$diff)";
  53. foreach my $p (sieve_prime_cluster(1079253721703, 5e12, @$diff)) {
  54. say $p if isok($p);
  55. }
  56. }
  57. __END__
  58. [5129602609, 40602028559, 69528307577, 129007460609, 236659873633, 322320688171, 371170549153, 390581208473, 441568239503, 651686524243].each{|p|
  59. say n_primes(8, p+1).map{ _ - p }
  60. }
  61. [40, 54, 94, 108, 148, 214, 228, 250]
  62. [14, 54, 68, 108, 122, 162, 228, 330]
  63. [14, 80, 120, 186, 200, 240, 254, 266]
  64. [14, 54, 68, 108, 122, 240, 254, 258]
  65. [40, 54, 94, 108, 148, 214, 228, 276]
  66. [118, 132, 172, 186, 226, 292, 306, 340]
  67. [40, 54, 94, 108, 148, 214, 228, 244]
  68. [14, 54, 68, 186, 200, 240, 254, 276]
  69. [14, 54, 68, 186, 200, 240, 306, 314]
  70. [40, 54, 94, 160, 174, 214, 228, 234]