/
sieve_cluster.pl
87 lines (70 loc) · 4.17 KB
/
sieve_cluster.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/perl
# Primes p such that 8 consecutive primes starting with p are {1,2,3,4,5,6,7,8} modulo 13.
# https://oeis.org/A338394
use 5.014;
use ntheory qw(:all);
use experimental qw(signatures);
# New terms found:
# 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
# Also in the sequence with {1..9} modulo 13:
# 1824535827869
# 14161747729169
# 60628028874089
# 67754204383529
# 81240600887759
# 93595283908439
sub isok ($p) {
for (my $count = 1 ; $count <= 8 ; ++$count) {
$p % 13 == $count or return;
$p = next_prime($p);
}
return 1;
}
foreach my $p (
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,
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
) {
isok($p) || die "error for $p";
}
my %seen;
foreach my $diff (
[40, 54, 94, 160, 174, 214, 228, 234],
[40, 54, 94, 108, 148, 214, 228, 234],
[14, 54, 68, 134, 174, 240, 254, 260],
[14, 54, 68, 108, 174, 188, 254, 266],
[40, 54, 94, 108, 174, 214, 228, 328],
[40, 54, 94, 108, 148, 162, 202, 240],
[14, 54, 68, 108, 122, 188, 228, 284],
[66, 80, 120, 134, 174, 188, 254, 260],
#~ [40, 54, 94, 108, 148, 214, 228, 250],
#~ [14, 54, 68, 108, 122, 162, 228, 330],
#~ [14, 80, 120, 186, 200, 240, 254, 266],
#~ [14, 54, 68, 108, 122, 240, 254, 258],
#~ [40, 54, 94, 108, 148, 214, 228, 276],
#~ [118, 132, 172, 186, 226, 292, 306, 340],
#~ [40, 54, 94, 108, 148, 214, 228, 244],
#~ [14, 54, 68, 186, 200, 240, 254, 276],
#~ [14, 54, 68, 186, 200, 240, 306, 314],
#~ [40, 54, 94, 160, 174, 214, 228, 234],
) {
pop @$diff;
next if $seen{join(' ', @$diff)}++;
say ":: Testing with differences (@$diff)";
foreach my $p (sieve_prime_cluster(1079253721703, 5e12, @$diff)) {
say $p if isok($p);
}
}
__END__
[5129602609, 40602028559, 69528307577, 129007460609, 236659873633, 322320688171, 371170549153, 390581208473, 441568239503, 651686524243].each{|p|
say n_primes(8, p+1).map{ _ - p }
}
[40, 54, 94, 108, 148, 214, 228, 250]
[14, 54, 68, 108, 122, 162, 228, 330]
[14, 80, 120, 186, 200, 240, 254, 266]
[14, 54, 68, 108, 122, 240, 254, 258]
[40, 54, 94, 108, 148, 214, 228, 276]
[118, 132, 172, 186, 226, 292, 306, 340]
[40, 54, 94, 108, 148, 214, 228, 244]
[14, 54, 68, 186, 200, 240, 254, 276]
[14, 54, 68, 186, 200, 240, 306, 314]
[40, 54, 94, 160, 174, 214, 228, 234]