Triplet of three numbers: Difference between revisions
→{{header|ALGOL 68}}: Use ALGOL 68-primes
m (→{{header|REXX}}: added filter comments, optimized the GENP subroutine.) |
(→{{header|ALGOL 68}}: Use ALGOL 68-primes) |
||
Line 7:
=={{header|ALGOL 68}}==
{{libheader|ALGOL 68-primes}}
<lang algol68>BEGIN # find numbers n where n-1, n+3 and n+5 are prime #
# sieve the primes up to
PR read "primes.incl.a68" PR
# returns a string represention of n #
OP TOSTRING = ( INT n )STRING: whole( n, 0 );
Line 22 ⟶ 17:
# 2 is clearly not a member of the required numbers, so we start at 3 #
INT n count := 0;
FOR n FROM 3 TO
IF prime[ n - 1 ] AND prime[ n + 3 ] AND prime[ n + 5 ] THEN
print( ( " (", TOSTRING n, " | ", TOSTRING ( n - 1 ), ", ", TOSTRING ( n + 3 ), ", ", TOSTRING ( n + 5 ), ")" ) );
|