Square but not cube: Difference between revisions

no edit summary
(Added Quackery.)
No edit summary
Line 1,702:
Same as Ring example.
</pre>
 
=={{header|Ksh}}==
<lang ksh>
#!/bin/ksh
 
# First 30 positive integers which are squares but not cubes
# also, the first 3 positive integers which are both squares and cubes
 
######
# main #
######
 
integer n sq cr cnt=0
 
for (( n=1; cnt<30; n++ )); do
(( sq = n * n ))
(( cr = cbrt(sq) ))
if (( (cr * cr * cr) != sq )); then
(( cnt++ ))
print ${sq}
else
print "${sq} is square and cube"
fi
done</lang>
{{out}}<pre>
1 is square and cube
4
9
16
25
36
49
64 is square and cube
81
100
121
144
169
196
225
256
289
324
361
400
441
484
529
576
625
676
729 is square and cube
784
841
900
961
1024
1089</pre>
 
=={{header|LOLCODE}}==
70

edits