Factorial primes: Difference between revisions

Content added Content deleted
(→‎{{header|Wren}}: More efficient basic version.)
Line 30: Line 30:
=={{header|ALGOL 68}}==
=={{header|ALGOL 68}}==
Basic task. Assumes LONG INT is at least 64 bits.
Basic task. Assumes LONG INT is at least 64 bits.
<lang algol68>BEGIN # find some factorial primes - primes that are f - 1 or f + 1 #
<lang algol68>BEGIN # find some factorial primes - primes that are f - 1 or f + 1 #
# foe some factorial f #
# for some factorial f #


# is prime PROC based on the one in the primality by trial division task #
# is prime PROC based on the one in the primality by trial division task #
Line 42: Line 42:
prime
prime
FI;
FI;
# end of code from the primality by trial divisio task #
# end of code based on the primality by trial divisio task #
PROC show factorial prime = ( INT fp number, INT n, CHAR fp op, LONG INT fp )VOID:
PROC show factorial prime = ( INT fp number, INT n, CHAR fp op, LONG INT fp )VOID:
Line 51: Line 51:
);
);
LONG INT f := 1;
LONG INT f := 1;
INT fp count := 0;
INT fp count := 0;
FOR n WHILE fp count < 10 DO
FOR n WHILE fp count < 10 DO
f *:= n;
f *:= n;
LONG INT fp := f - 1;
IF LONG INT fp = f - 1;
IF is prime( fp )
is prime( fp )
THEN
THEN
fp count +:= 1;
show factorial prime( fp count +:= 1, n, "-", fp )
show factorial prime( fp count, n, "-", fp )
FI;
FI;
fp +:= 2;
IF LONG INT fp = f + 1;
IF is prime( fp )
is prime( fp )
THEN
THEN
fp count +:= 1;
show factorial prime( fp count +:= 1, n, "+", fp )
show factorial prime( fp count, n, "+", fp )
FI
FI
OD
OD