Factorial primes: Difference between revisions

→‎{{header|ALGOL 68}}: Simplified also make it more DRY and less WET
(Added Sidef)
(→‎{{header|ALGOL 68}}: Simplified also make it more DRY and less WET)
Line 31:
=={{header|ALGOL 68}}==
Basic task. Assumes LONG INT is at least 64 bits.
<syntaxhighlight lang="algol68">BEGIN # find some factorial primes - primes that are f - 1 or f + 1 #
BEGIN # find some factorial primes - primes that are f - 1 or f + 1 #
# for some factorial f #
 
Line 43 ⟶ 44:
prime
FI;
# end of code based on the primality by trial divisiodivision task #
PROC show factorial prime = ( INT fp number, INT n, CHAR fp op, LONG INT fp )VOID:
print( ( whole( fp number, -2 ), ":", whole( n, -4 )
, "! ", fp op, " 1 = ", whole( fp, 0 )
, newline
)
);
LONG INT f := 1;
INT fp count := 0;
FOR n WHILE fp count < 10 DO
f *:= n;
IFCHAR fp LONG INT fpop := f "- 1";
FOR offset FROM -1 isBY prime(2 fpTO )1 DO
IF LONG INT fp = f + offset;
THEN
show factorial prime( fp countis +:= 1, n, "-",prime( fp )
FI; THEN
IF LONG INT fp = f print( ( whole( fp count +:= 1;, -2 ), ":", whole( n, -4 )
is prime , "! ", fp op, " 1 = ", whole( fp, 0 )
THEN , newline
show factorial prime( fp count +:= 1, n, "+", fp )
FI )
)FI;
fp op ,:= newline"+"
); OD
OD
END
END</syntaxhighlight>
{{out}}
<pre>
3,028

edits