Smallest square that begins with n: Difference between revisions
Content added Content deleted
m (→{{header|Wren}}: Minor tidy) |
Not a robot (talk | contribs) (Add ABC) |
||
Line 68: | Line 68: | ||
49 |
49 |
||
</pre> |
</pre> |
||
=={{header|ABC}}== |
|||
<syntaxhighlight lang="ABC">HOW TO REPORT n begins.with m: |
|||
SELECT: |
|||
n<m: FAIL |
|||
n=m: SUCCEED |
|||
n>m: REPORT (floor (n/10)) begins.with m |
|||
HOW TO RETURN first.square.with.prefix n: |
|||
PUT 1 IN sq.root |
|||
WHILE NOT (sq.root**2) begins.with n: |
|||
PUT sq.root+1 IN sq.root |
|||
RETURN sq.root**2 |
|||
FOR i IN {0..49}: |
|||
WRITE (first.square.with.prefix i)>>7 |
|||
IF i mod 10 = 9: WRITE /</syntaxhighlight> |
|||
{{out}} |
|||
<pre> 1 1 25 36 4 529 64 729 81 9 |
|||
100 1156 121 1369 144 1521 16 1764 1849 196 |
|||
2025 2116 225 2304 2401 25 2601 2704 289 2916 |
|||
3025 3136 324 3364 3481 35344 36 3721 3844 3969 |
|||
400 41209 4225 4356 441 45369 4624 4761 484 49</pre> |
|||
=={{header|Action!}}== |
=={{header|Action!}}== |