Giuga numbers: Difference between revisions

→‎{{header|Euler}}: Sybntax highlight with Mediawiki markup
imported>Maxima enthusiast
No edit summary
(→‎{{header|Euler}}: Sybntax highlight with Mediawiki markup)
Line 551:
=={{header|Euler}}==
Uses the C style for loop procedure from the [[Sieve of Eratosthenes]] task
'''begin'''
<syntaxhighlight lang="euler">
'''new''' for; '''new''' n; '''new''' gCount;
begin
for &lt;- ` '''formal''' init; '''formal''' test; '''formal''' incr; '''formal''' body;
new for; new n; new gCount;
for <- ` formal init; formal test; formal incr; formal body;'''begin'''
begin '''label''' again;
label againinit;
again: '''if''' test '''then''' '''begin''' body; incr; '''goto''' again '''end''' '''else''' 0
init;
again: if test then begin body; incr; goto again '''end else 0'''
end&apos;
';
gCount &lt;- 0;
for( ` n &lt;- 2 &apos;, ` gCount &lt; 4 &apos;, ` n &lt;- n + 4 &apos;
gCount <- 0;
for( ` n <- 2 ', ` gCount < 4 ', ` n <- n + 4 ''begin'''
'''new''' v; '''new''' f; '''new''' isGiuga; '''new''' fCount;
, ` begin
new v; new f; new isGiuga &lt;- n new% fCount2;
v isGiuga <&lt;- n % 2'''true''';
isGiuga <fCount &lt;- true1;
for( ` f &lt;- 3 &apos;, ` f &lt;= v '''and''' isGiuga &apos;, ` f &lt;- f + 2 &apos;
fCount <- 1;
for( ` f <- 3 ', ` f <='''if''' v and isGiuga ', `''mod''' f <-= f0 + 2'''then''' '''begin'''
, ` if v mod f = 0 thenfCount begin &lt;- fCount + 1;
fCount isGiuga <&lt;- fCount[ +[ n % f ] - 1 ] '''mod''' f = 0;
isGiuga <v &lt;- [ [ nv % f ] - 1 ] mod f = 0;
'''end''' '''else''' v <- v % f0
end else 0&apos;
');
'''if''' isGiuga );'''then''' '''begin'''
'''if''' fCount &gt; isGiuga1 '''then''' '''begin'''
if fCount > 1 thengCount begin&lt;- gCount + 1;
gCount <-'''out''' gCount + 1;n
'''end''' '''else''' out n0
'''end''' '''else''' 0
'''end else 0'''
end&apos;
')
'''end''' $
)
end $
</syntaxhighlight>
 
=={{header|Go}}==
3,021

edits