Steady squares: Difference between revisions
added Arturo implementation
Drkameleon (talk | contribs) (added Arturo implementation) |
|||
Line 123:
9376^2: 87909376
</pre>
=={{header|Arturo}}==
<syntaxhighlight lang="arturo">steady?: function [n][
mask: 1
d: n
while -> d <> 0 [
mask: mask * 10
d: d / 10
]
n = (n * n) % mask
]
loop 0..1000 'n [
loop [1 5 6] 'd [
r: d + 10 * n ; only check numbers that end with 1, 5, 6
if steady? r -> print ~"|r|^2 = |r*r|"
]
]</syntaxhighlight>
{{out}}
<pre>1^2 = 1
5^2 = 25
6^2 = 36
25^2 = 625
76^2 = 5776
376^2 = 141376
625^2 = 390625
9376^2 = 87909376</pre>
=={{header|AWK}}==
|