Sequence of primorial primes: Difference between revisions

Added Algol 68
m (elided a blank.)
(Added Algol 68)
Line 30:
* [https://oeis.org/A088411 Sequence A088411] from The On-Line Encyclopedia of Integer Sequences
<br><br>
 
=={{header|ALGOL 68}}==
Uses ALGOL 68G's LONG LONG INT which has programmer-speciafable precision. The precision used and size of the prime sieve used would allow finding the sequence up to 16 members, though that would take some time.
{{works with|ALGOL 68G|Any - tested with release 3.0.3.win32}}
{{libheader|ALGOL 68-primes}}
NB: The source of the ALGOL 68 primes library is on a Rosetta Code page.<br>
NB: ALGOL 68G version 3 will issue warnings for unused items and names hiding names in outer scopes for the primes.incl.a68 file.
<lang algol68>BEGIN # find some primorial primes - primes that are p - 1 or p + 1 #
# for some primorial p #
PR precision 2000 PR # allow up to 2000 digit numbers #
PR read "primes.incl.a68" PR # include prime utilities #
# construct a sieve of primes up to 2000 #
[]BOOL primes = PRIMESIEVE 2000;
# find the sequence members #
LONG LONG INT pn := 1;
INT p count := 0;
INT p pos := 0;
FOR n FROM 1 WHILE p count < 12 DO
# find the next prime #
WHILE NOT primes[ p pos +:= 1 ] DO SKIP OD;
pn *:= p pos;
IF is probably prime( pn - 1 )
THEN
p count +:= 1;
print( ( " ", whole( n, 0 ) ) )
ELIF is probably prime( pn + 1 )
THEN
p count +:= 1;
print( ( " ", whole( n, 0 ) ) )
FI
OD;
print( ( newline ) )
END</lang>
{{out}}
<pre>
1 2 3 4 5 6 11 13 24 66 68 75
</pre>
 
=={{header|C}}==
3,028

edits