Giuga numbers: Difference between revisions

1,217 bytes added ,  11 months ago
Added Euler
(Added PL/M)
(Added Euler)
Line 423:
n = 6: 24423128562 2214408306
</pre>
 
=={{header|Euler}}==
Uses the C style for loop procedure from the [[Sieve of Eratosthenes]] task
<syntaxhighlight lang="euler">
begin
new for; new n; new gCount;
for <- ` formal init; formal test; formal incr; formal body;
begin
label again;
init;
again: if test then begin body; incr; goto again end else 0
end
'
;
gCount <- 0;
for( ` n <- 2 ', ` gCount < 4 ', ` n <- n + 4 '
, ` begin
new v; new f; new isGiuga; new fCount;
v <- n % 2;
isGiuga <- true;
fCount <- 1;
for( ` f <- 3 ', ` f <= v and isGiuga ', ` f <- f + 2 '
, ` if v mod f = 0 then begin
fCount <- fCount + 1;
isGiuga <- [ [ n % f ] - 1 ] mod f = 0;
v <- v % f
end else 0
'
);
if isGiuga then begin
if fCount > 1 then begin
gCount <- gCount + 1;
out n
end else 0
end else 0
end
'
)
end $
</syntaxhighlight>
 
=={{header|Go}}==
3,022

edits