Prime numbers whose neighboring pairs are tetraprimes: Difference between revisions

Added XPL0 example.
(Changed average to median.)
(Added XPL0 example.)
Line 157:
Median gap between those 10,551 primes : 660
Maximum gap between those 10,551 primes : 10,284
</pre>
 
=={{header|XPL0}}==
<syntaxhighlight lang "XPL0">include xpllib; \for Print
 
int Have7; \A tetraprime factor is 7
 
proc IsTetraprime(N); \Return 'true' if N is a tetraprime
int N;
int Div, Count, Distinct;
[Div:= 2; Count:= 0;
while N >= Div*Div do
[Distinct:= true;
while rem(N/Div) = 0 do
[if not Distinct then return false;
Distinct:= false;
Count:= Count+1;
if Div = 7 then Have7:= true;
N:= N/Div;
];
Div:= Div+1;
];
if N > 1 then Count:= Count+1;
return Count = 4;
];
 
int Sign, TenPower, TP, Case, N, N0, Count, Count7, Gap, GapMin, GapMax, GapSum;
[Sign:= -1; TenPower:= 100_000;
for TP:= 5 to 7 do
[for Case:= 1 to 2 do \preceding or following neighboring pairs
[Count:= 0; Count7:= 0; N0:= 0; GapMin:= -1>>1; GapMax:= 0; GapSum:= 0;
if TP = 5 then CrLf(0); \100_000
for N:= 3 to TenPower-1 do
[if IsPrime(N) then
[Have7:= false;
if IsTetraprime(N+1*Sign) then
if IsTetraprime(N+2*Sign) then
[Count:= Count+1;
if TP = 5 then
[Print("%7d", N);
if rem(Count/10) = 0 then CrLf(0);
];
if Have7 then Count7:= Count7+1;
if N0 # 0 then
[Gap:= N - N0;
if Gap < GapMin then GapMin:= Gap;
if Gap > GapMax then GapMax:= Gap;
GapSum:= GapSum + Gap;
];
N0:= N;
];
];
N:= N+1;
];
Print("\nFound %,d primes under %,d whose neighboring pair are tetraprimes\n",
Count, TenPower);
Print("of which %,d have a neighboring pair, one of whose factors is 7.\n\n",
Count7);
Print("Minimum gap between %d primes : %,d\n", Count, GapMin);
Print("Average gap between %d primes : %,d\n", Count,
fix(float(GapSum)/float(Count-1)));
Print("Maximum gap between %d primes : %,d\n", Count, GapMax);
Sign:= Sign * -1;
];
TenPower:= TenPower * 10;
];
]</syntaxhighlight>
{{out}}
<pre>
 
8647 15107 20407 20771 21491 23003 23531 24767 24971 27967
29147 33287 34847 36779 42187 42407 42667 43331 43991 46807
46867 51431 52691 52747 53891 54167 58567 63247 63367 69379
71711 73607 73867 74167 76507 76631 76847 80447 83591 84247
86243 87187 87803 89387 93887 97547 97847 98347 99431
Found 49 primes under 100,000 whose neighboring pair are tetraprimes
of which 31 have a neighboring pair, one of whose factors is 7.
 
Minimum gap between 49 primes : 56
Average gap between 49 primes : 1,891
Maximum gap between 49 primes : 6,460
 
8293 16553 17389 18289 22153 26893 29209 33409 35509 36293
39233 39829 40493 41809 45589 48109 58393 59629 59753 59981
60493 60913 64013 64921 65713 66169 69221 71329 74093 75577
75853 77689 77933 79393 79609 82913 84533 85853 87589 87701
88681 91153 93889 96017 97381 98453
Found 46 primes under 100,000 whose neighboring pair are tetraprimes
of which 36 have a neighboring pair, one of whose factors is 7.
 
Minimum gap between 46 primes : 112
Average gap between 46 primes : 2,004
Maximum gap between 46 primes : 10,284
 
Found 885 primes under 1,000,000 whose neighboring pair are tetraprimes
of which 503 have a neighboring pair, one of whose factors is 7.
 
Minimum gap between 885 primes : 4
Average gap between 885 primes : 1,119
Maximum gap between 885 primes : 7,712
 
Found 866 primes under 1,000,000 whose neighboring pair are tetraprimes
of which 492 have a neighboring pair, one of whose factors is 7.
 
Minimum gap between 866 primes : 4
Average gap between 866 primes : 1,146
Maximum gap between 866 primes : 10,284
 
Found 10,815 primes under 10,000,000 whose neighboring pair are tetraprimes
of which 5,176 have a neighboring pair, one of whose factors is 7.
 
Minimum gap between 10815 primes : 4
Average gap between 10815 primes : 924
Maximum gap between 10815 primes : 9,352
 
Found 10,551 primes under 10,000,000 whose neighboring pair are tetraprimes
of which 5,069 have a neighboring pair, one of whose factors is 7.
 
Minimum gap between 10551 primes : 4
Average gap between 10551 primes : 947
Maximum gap between 10551 primes : 10,284
</pre>
291

edits