Giuga numbers: Difference between revisions
→{{header|ALGOL 68}}: Must spell Giuga correctly
(Added Algol 68) |
(→{{header|ALGOL 68}}: Must spell Giuga correctly) |
||
Line 67:
=={{header|ALGOL 68}}==
<syntaxhighlight lang="algol68">
BEGIN # find some
# prime factors f exactly divide ( n / f ) - 1 #
# find the first four
INT g count := 0;
FOR n FROM 2 WHILE g count < 4 DO
INT v := n;
BOOL is
INT f count := 0;
IF NOT ODD v THEN
# 2 is a prime factor of n #
is
IF is
f count +:= 1;
WHILE v MOD 2 = 0 DO v OVERAB 2 OD
FI
FI;
IF is
FOR f FROM 3 BY 2 WHILE f <= v AND is
IF v MOD f = 0 THEN
# have a prime factor #
f count +:= 1;
is
IF is
# n is still a candidate #
v OVERAB f;
Line 97:
FI
OD;
IF is
# n is still a candidate, check it is not prime #
is
FI
FI;
IF is
g count +:= 1;
print( ( " ", whole( n, 0 ) ) )
|