Jump to content

Factorial primes: Difference between revisions

(→‎{{header|Wren}}: More efficient basic version.)
Line 30:
=={{header|ALGOL 68}}==
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 #
# foe for some factorial f #
 
# is prime PROC based on the one in the primality by trial division task #
Line 42:
prime
FI;
# end of code frombased on the primality by trial divisio task #
PROC show factorial prime = ( INT fp number, INT n, CHAR fp op, LONG INT fp )VOID:
Line 51:
);
LONG INT f := 1;
INT fp count := 0;
FOR n WHILE fp count < 10 DO
f *:= n;
IF LONG INT fp := f - 1;
IF is prime( fp )
THEN
show factorial prime( fp count +:= 1;, n, "-", fp )
show factorial prime( fp count, n, "-", fp )
FI;
IF LONG INT fp +:= 2f + 1;
IF is prime( fp )
THEN
show factorial prime( fp count +:= 1;, n, "+", fp )
show factorial prime( fp count, n, "+", fp )
FI
OD
3,049

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.