Square but not cube

Revision as of 07:39, 9 August 2018 by CalmoSoft (talk | contribs) (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...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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>

  1. 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