Prime numbers whose neighboring pairs are tetraprimes: Difference between revisions

(Added Go)
(→‎{{header|ALGOL 68}}: Added stretch)
Line 37:
{{works with|ALGOL 68G|Any - tested with release 2.8.3.win32}}
{{libheader|ALGOL 68-rows}}
Constructs a table of prime factors without using division/modulo ooperationsoperations.<br>
To run this wityth Algol 68G, you will need to specify a large heap size, with e.g.: <code>-heap 256M</code> on the command line.
<syntaxhighlight lang="algol68">
BEGIN # find primes whose neighbouring pairs are tetraprimes - i.e. have 4 #
Line 79 ⟶ 80:
BEGIN
# array of prime gaps, used to find the median gap #
# should be large enough for the basicstretch task, a flexible array #
#[ could1 be: used12 and000 expanded]INT ingaps; sizeFOR ifi necessaryTO UPB gaps DO gaps[ i ] := 0 #OD;
[ 1 : 1000 ]INT gaps; FOR i TO UPB gaps DO gaps[ i ] := 0 OD;
INT t count := 0, f7 count := 0;
INT prev prime := 0;
Line 130:
 
# task #
show tetraprime neighbours( 100 000, TRUE );
show tetraprime neighbours( 1 000 000, FALSE );
show tetraprime neighbours( 10 000 000, FALSE )
 
END
Line 162 ⟶ 163:
Found 866 such primes of which 492 have 7 as a factor of one of the pair
gaps between the primes: min: 4, average: 1146, median: 832, max: 10284
 
Primes below 10000000 preceded by a tetraprime pair:
Found 10815 such primes of which 5176 have 7 as a factor of one of the pair
gaps between the primes: min: 4, average: 924, median: 648, max: 9352
 
Primes below 10000000 followed by a tetraprime pair:
Found 10551 such primes of which 5069 have 7 as a factor of one of the pair
gaps between the primes: min: 4, average: 947, median: 660, max: 10284
</pre>
 
3,026

edits