Steady squares: Difference between revisions

Line 886:
issteady=: (": -: -@#@": {. ":@*:)"0 NB. tacit alternative</syntaxhighlight>Task example:<syntaxhighlight lang="j"> I.issteady i.1e4
0 1 5 6 25 76 376 625 9376</syntaxhighlight>Note that for larger values we would want to take advantage of the suffix characteristics of these numbers (a multi-digit steady square would have a suffix which is a steady square).
 
For example:
<syntaxhighlight lang=J>bigsteady=: {{
Y=. 1+s=.0x
whilst. Y < y do.
s=. (#~ issteady) ,(Y*i.10)+/s
Y=. Y*10
end.
s #~ y>s
}}</syntaxhighlight>
 
Example use:
 
<pre style="overflow-x: scroll; white-space:nowrap!important"> $bigsteady 1e20
37
$bigsteady 1e30
54
q:54
2 3 3 3
9 6$bigsteady 1e30
0 1 5 6 25 76
376 625 9376 90625 109376 890625
2890625 7109376 12890625 87109376 212890625 787109376
1787109376 8212890625 18212890625 81787109376 918212890625 9918212890625
40081787109376 59918212890625 259918212890625 740081787109376 3740081787109376 6259918212890625
43740081787109376 56259918212890625 256259918212890625 743740081787109376 2256259918212890625 7743740081787109376
92256259918212890625 392256259918212890625 607743740081787109376 2607743740081787109376 7392256259918212890625 22607743740081787109376
77392256259918212890625 977392256259918212890625 9977392256259918212890625 19977392256259918212890625 80022607743740081787109376 380022607743740081787109376
619977392256259918212890625 3380022607743740081787109376 6619977392256259918212890625 93380022607743740081787109376 106619977392256259918212890625 893380022607743740081787109376
</pre>
 
== {{header|JavaScript}} ==
6,951

edits