Square but not cube: Difference between revisions
Content added Content deleted
(Created page with "{{draft task}} =={{header|Ring}}== <lang ring> # Project : Square but not cube limit = 30 num = 0 sq = 0 while num < limit sq = sq + 1 sqpow = pow(sq,2) fla...") |
No edit summary |
||
Line 1: | Line 1: | ||
{{draft task}} |
{{draft task}} |
||
Show the first 30 square numbers which are not cube. |
|||
=={{header|Ring}}== |
=={{header|Ring}}== |
||
<lang ring> |
<lang ring> |
Revision as of 08:03, 9 August 2018
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.
Show the first 30 square numbers which are not cube.
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