Square but not cube: Difference between revisions
Content added Content deleted
Not a robot (talk | contribs) (Add CLU) |
(Added solution for Action!) |
||
Line 75: | Line 75: | ||
<pre>4 9 16 25 36 49 81 100 121 144 169 196 225 256 289 324 361 400 441 484 529 576 625 676 784 841 900 961 1024 1089 </pre> |
<pre>4 9 16 25 36 49 81 100 121 144 169 196 225 256 289 324 361 400 441 484 529 576 625 676 784 841 900 961 1024 1089 </pre> |
||
=={{header|Action!}}== |
|||
<lang Action!>BYTE FUNC IsCube(INT n) |
|||
INT i,c |
|||
i=1 |
|||
DO |
|||
c=i*i*i |
|||
IF c=n THEN |
|||
RETURN (1) |
|||
FI |
|||
i==+1 |
|||
UNTIL c>n |
|||
OD |
|||
RETURN (0) |
|||
PROC Main() |
|||
INT n,sq,count |
|||
PrintE("First 30 squares but not cubes:") |
|||
n=1 count=0 |
|||
WHILE count<30 |
|||
DO |
|||
sq=n*n |
|||
IF IsCube(sq)=0 THEN |
|||
PrintF("%I ",sq) |
|||
count==+1 |
|||
FI |
|||
n==+1 |
|||
OD |
|||
PutE() PutE() |
|||
PrintE("First 3 squares and cubes:") |
|||
n=1 count=0 |
|||
WHILE count<3 |
|||
DO |
|||
sq=n*n |
|||
IF IsCube(sq) THEN |
|||
PrintF("%I ",sq) |
|||
count==+1 |
|||
FI |
|||
n==+1 |
|||
OD |
|||
RETURN</lang> |
|||
{{out}} |
|||
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Square_but_not_cube.png Screenshot from Atari 8-bit computer] |
|||
<pre> |
|||
First 30 squares but not cubes: |
|||
4 9 16 25 36 49 81 100 121 144 169 196 225 256 289 324 361 400 441 484 529 576 625 676 784 841 900 961 1024 1089 |
|||
First 3 squares and cubes: |
|||
1 64 729 |
|||
</pre> |
|||
=={{header|Ada}}== |
=={{header|Ada}}== |