Sum of first n cubes: Difference between revisions
(Created page with "{{Draft task}} ;Task: Find and show sum of first n cubes, where '''n < 51''' <br><br> =={{header|Ring}}== <lang ring> see "working..." + nl see "Sum of first n cubes:" + nl...") |
m (CalmoSoft moved page Som of first n cubes to Sum of first n cubes) |
(No difference)
|
Revision as of 06:46, 19 May 2021
Sum of first n cubes 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
Find and show sum of first n cubes, where n < 51
Ring
<lang ring> see "working..." + nl see "Sum of first n cubes:" + nl row = 0 lenCubes = 50
for n = 1 to lenCubes
sumCubes = 0 for m = 1 to n sumCubes = sumCubes + pow(m,3) next row = row + 1 see "" + sumCubes + " " if row%5 = 0 see nl ok
next
see "Found " + row + " cubes" + nl see "done..." + nl </lang>
- Output:
working... Sum of first n cubes: 1 9 36 100 225 441 784 1296 2025 3025 4356 6084 8281 11025 14400 18496 23409 29241 36100 44100 53361 64009 76176 90000 105625 123201 142884 164836 189225 216225 246016 278784 314721 354025 396900 443556 494209 549081 608400 672400 741321 815409 894916 980100 1071225 1168561 1272384 1382976 1500625 1625625 Found 50 cubes done...