Digit fifth powers: Difference between revisions
Content added Content deleted
(Created page with "{{Draft task}} ;Task: <br>Task desciption is taken from Project Eulet(https://projecteuler.net/problem=30) <br>Find the sum of all the numbers that can be written as the sum...") |
(Blanked the page) |
||
Line 1: | Line 1: | ||
{{Draft task}} |
|||
;Task: |
|||
<br>Task desciption is taken from Project Eulet(https://projecteuler.net/problem=30) |
|||
<br>Find the sum of all the numbers that can be written as the sum of fifth powers of their digits. |
|||
<br><br> |
|||
=={{header|Ring}}== |
|||
<lang ring> |
|||
see "working..." + nl |
|||
sumEnd = 0 |
|||
sumList = [] |
|||
limitStart = 10000 |
|||
limitEnd = 99999 |
|||
for n = limitStart to limitEnd |
|||
sum = 0 |
|||
nStr = string(n) |
|||
for m = 1 to len(nStr) |
|||
sum = sum + pow(number(nStr[m]),5) |
|||
next |
|||
if sum = n |
|||
add(sumList,n) |
|||
sumEnd += n |
|||
ok |
|||
next |
|||
see "The sum of all the numbers that can be written as the sum of fifth powers of their digits:" + nl |
|||
for n = 1 to len(sumList)-1 |
|||
see "" + sumList[n] + " + " |
|||
next |
|||
see "" + sumList[n] + " = " + sumEnd + nl |
|||
see "done..." + nl |
|||
</lang> |
|||
{{out}} |
|||
<pre> |
|||
working... |
|||
The sum of all the numbers that can be written as the sum of fifth powers of their digits: |
|||
54748 + 92727 + 93084 = 240559 |
|||
done... |
|||
</pre> |