How to resolve the algorithm Square but not cube step by step in the Ring programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Square but not cube step by step in the Ring programming language
Table of Contents
Problem Statement
Show the first 30 positive integers which are squares but not cubes of such integers. Optionally, show also the first 3 positive integers which are both squares and cubes, and mark them as such.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Square but not cube step by step in the Ring programming language
Source code in the ring programming language
# 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
You may also check:How to resolve the algorithm Zero to the zero power step by step in the Ruby programming language
You may also check:How to resolve the algorithm Xiaolin Wu's line algorithm step by step in the Wren programming language
You may also check:How to resolve the algorithm Closest-pair problem step by step in the PureBasic programming language
You may also check:How to resolve the algorithm Compare a list of strings step by step in the XPL0 programming language
You may also check:How to resolve the algorithm Higher-order functions step by step in the NewLISP programming language