Square but not cube
Square but not cube 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.
Ring
<lang ring>
- Project : Square but not cube
limit = 30 num = 0 sq = 0 while num < limit
sq = sq + 1 sqpow = pow(sq,2) flag = iscube(sqpow) if flag = 0 num = num + 1 see sqpow + nl else see "" + sqpow + " is square and cube" + nl ok
end
func iscube(cube)
for n = 1 to cube if pow(n,3) = cube return 1 ok next return 0
</lang> Output:
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