Steady squares: Difference between revisions
Content added Content deleted
m (→{{header|Wren}}: Changed to Wren S/H) |
(Added ABC) |
||
Line 4: | Line 4: | ||
<br> |
<br> |
||
The 3-digit number 376 in the decimal numbering system is an example of numbers with the special property that its square ends with the same digits: '''376*376 = 141376'''. Let's call a number with this property a steady square. Find steady squares under '''10.000''' |
The 3-digit number 376 in the decimal numbering system is an example of numbers with the special property that its square ends with the same digits: '''376*376 = 141376'''. Let's call a number with this property a steady square. Find steady squares under '''10.000''' |
||
=={{header|ABC}}== |
|||
<syntaxhighlight lang="abc"> |
|||
HOW TO REPORT n is.steady.square power.of.ten: |
|||
REPORT ( n * n ) mod power.of.ten = n |
|||
HOW TO REPORT n show.possible.steady.square power.of.ten: |
|||
IF n is.steady.square power.of.ten: |
|||
WRITE ( ( ( n << 1 ) ^ "^2 = " ) >> 10 ) ^ ( ( n * n ) >> 1 ) / |
|||
SUCCEED |
|||
PUT 10 IN power.of.ten |
|||
PUT -10 IN n |
|||
FOR i IN { 0 .. 1000 }: |
|||
PUT n + 10 IN n |
|||
IF n = power.of.ten: |
|||
PUT power.of.ten * 10 IN power.of.ten |
|||
IF ( n + 1 ) show.possible.steady.square power.of.ten: PASS |
|||
IF ( n + 5 ) show.possible.steady.square power.of.ten: PASS |
|||
IF ( n + 6 ) show.possible.steady.square power.of.ten: PASS |
|||
</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|Action!}}== |
=={{header|Action!}}== |