Steady squares: Difference between revisions
Content added Content deleted
(→{{header|Lua}}: notes) |
(→{{header|Euler}}: Sybntax highlight with Mediawiki markup) |
||
Line 786: | Line 786: | ||
<br> |
<br> |
||
Everything is Euler is an expression (apart from new/label/formal) and returns a value (although the value of a "goto" can't be used), so the "else" part of an "if" is not optional, hence the "else 0"s appearing in the code below. |
Everything is Euler is an expression (apart from new/label/formal) and returns a value (although the value of a "goto" can't be used), so the "else" part of an "if" is not optional, hence the "else 0"s appearing in the code below. |
||
⚫ | |||
<syntaxhighlight lang="euler"> |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
'''label''' again; |
|||
again: '''if''' condition '''then''' '''begin''' loopBody; '''goto''' again '''end''' '''else''' 0 |
|||
⚫ | |||
'''end''' |
|||
' |
|||
; |
|||
; |
|||
maxNumber <- 10 000; |
|||
powerOfTen <- 10; |
|||
lastDigit <- ( 1, 5, 6 ); |
|||
powerOfTen <- 10; |
|||
n <- -10; |
|||
while( ` [ n <- n + 10 ] <= maxNumber ' |
|||
n <- -10; |
|||
, ` '''begin''' |
|||
'''new''' d; |
|||
'''if''' n = powerOfTen '''then''' powerOfTen <- powerOfTen * 10 |
|||
new d; |
|||
'''else''' 0; |
|||
d <- 0; |
|||
d |
while( ` [ d <- d + 1 ] <= '''length''' lastDigit ' |
||
, ` '''begin''' |
|||
'''new''' nd; '''new''' n2; |
|||
nd <- n + lastDigit[ d ]; |
|||
n2 <- nd * nd; |
|||
n2 |
'''if''' n2 '''mod''' powerOfTen = nd '''then''' '''out''' nd '''else''' 0 |
||
'''end''' |
|||
' |
|||
) |
|||
'''end''' |
|||
' |
|||
) |
|||
'''end''' |
|||
) |
|||
⚫ | |||
end |
|||
⚫ | |||
</syntaxhighlight> |
|||
{{out}} |
{{out}} |
||
<pre> |
<pre> |