Square but not cube: Difference between revisions

Content added Content deleted
(→‎{{header|Common Lisp}}: generate squares and check for cubes instead of checking all whole numbers for both)
(→‎{{header|Commodore BASIC}}: Add implementation)
Line 695: Line 695:
1024
1024
1089</pre>
1089</pre>

=={{header|Commodore BASIC}}==
{{trans|BASIC}}
<lang basic>100 DIM SC(2):SC=0: REM REMEMBER SQUARE CUBES
110 PRINT "SQUARES BUT NOT CUBES:"
120 I=1: CU=1: SQ=1: RT=1: NC=0
130 IF N=30 THEN 200
140 SQ=I*I
150 IF SQ > CU THEN RT=RT+1: CU=RT*RT*RT: GOTO 150
160 IF SQ = CU THEN SC(SC)=SQ:SC=SC+1
170 IF SQ < CU THEN N=N+1:PRINT SQ,
180 I=I+1
190 GOTO 130
200 PRINT: PRINT
210 PRINT "BOTH SQUARES AND CUBES:"
220 FOR I=0 TO SC-1:PRINT SC(I),:NEXT I
230 PRINT</lang>

{{Out}}
<pre>
READY.
RUN
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

BOTH SQUARES AND CUBES:
1 64 729

READY.
</pre>


=={{header|Common Lisp}}==
=={{header|Common Lisp}}==