Giuga numbers: Difference between revisions
Content added Content deleted
imported>Maxima enthusiast No edit summary |
(→{{header|Euler}}: Sybntax highlight with Mediawiki markup) |
||
Line 551: | Line 551: | ||
=={{header|Euler}}== |
=={{header|Euler}}== |
||
Uses the C style for loop procedure from the [[Sieve of Eratosthenes]] task |
Uses the C style for loop procedure from the [[Sieve of Eratosthenes]] task |
||
⚫ | |||
<syntaxhighlight lang="euler"> |
|||
⚫ | |||
⚫ | |||
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 |
|||
init; |
|||
'''end''' |
|||
' |
|||
; |
|||
gCount <- 0; |
|||
for( ` n <- 2 ', ` gCount < 4 ', ` n <- n + 4 ' |
|||
gCount <- 0; |
|||
, ` '''begin''' |
|||
'''new''' v; '''new''' f; '''new''' isGiuga; '''new''' fCount; |
|||
, ` begin |
|||
v <- n % 2; |
|||
isGiuga <- '''true'''; |
|||
fCount <- 1; |
|||
for( ` f <- 3 ', ` f <= v '''and''' isGiuga ', ` f <- f + 2 ' |
|||
fCount <- 1; |
|||
, ` '''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 |
'''if''' fCount > 1 '''then''' '''begin''' |
||
gCount <- gCount + 1; |
|||
'''out''' n |
|||
'''end''' '''else''' 0 |
|||
'''end''' '''else''' 0 |
|||
'''end''' |
|||
' |
|||
) |
|||
⚫ | |||
) |
|||
⚫ | |||
</syntaxhighlight> |
|||
=={{header|Go}}== |
=={{header|Go}}== |