Sum of first n cubes: Difference between revisions
Content added Content deleted
Not a robot (talk | contribs) (Add CLU) |
(Added solution for Action!) |
||
Line 4: | Line 4: | ||
Find and show sum of first '''n''' cubes, where '''n < 50''' (ie show 50 entries for n=0..49) |
Find and show sum of first '''n''' cubes, where '''n < 50''' (ie show 50 entries for n=0..49) |
||
<br><br> |
<br><br> |
||
=={{header|Action!}}== |
|||
{{libheader|Action! Tool Kit}} |
|||
<lang Action!>INCLUDE "D2:REAL.ACT" ;from the Action! Tool Kit |
|||
PROC Main() |
|||
BYTE i |
|||
REAL sum,r3,tmp1,tmp2 |
|||
Put(125) PutE() ;clear the screen |
|||
IntToReal(0,sum) |
|||
IntToReal(3,r3) |
|||
FOR i=0 TO 49 |
|||
DO |
|||
IntToReal(i,tmp1) |
|||
RealMult(tmp1,tmp1,tmp2) |
|||
RealMult(tmp1,tmp2,tmp2) |
|||
RealAdd(sum,tmp2,sum) |
|||
PrintR(sum) Put(32) |
|||
IF i MOD 4=3 THEN |
|||
PutE() |
|||
FI |
|||
OD |
|||
RETURN</lang> |
|||
{{out}} |
|||
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Sum_of_first_n_cubes.png Screenshot from Atari 8-bit computer] |
|||
<pre> |
|||
0 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 |
|||
</pre> |
|||
=={{header|Ada}}== |
=={{header|Ada}}== |