Steady squares: Difference between revisions

From Rosetta Code
Content added Content deleted
(Created page with "{{Draft task}} ;Task: <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...")
 
No edit summary
Line 3: Line 3:
;Task:
;Task:
<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 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|Ring}}==
=={{header|Ring}}==
<lang ring>
<lang ring>

Revision as of 06:47, 21 December 2021

Steady squares is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.
Task


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

Ring

<lang ring> see "working..." +nl limit = 10000

for n = 1 to limit

   nstr = string(n)
   len = len(nstr)
   square = pow(n,2)
   rn = right(string(square),len)
   if nstr = rn
      see "" + n + " " + square + nl
   ok

next

see "done..." +nl </lang>

Output:
working...
Steady numbers under 10.000 are:
1 1
5 25
6 36
25 625
76 5776
376 141376
625 390625
9376 87909376
done...