Task

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.




BYTE FUNC IsCube(INT n)
  INT i,c
 
  i=1
  DO
    c=i*i*i
    IF c=n THEN
      RETURN (1)
    FI
    i==+1
  UNTIL c>n
  OD
RETURN (0)
 
PROC Main()
  INT n,sq,count
 
  PrintE("First 30 squares but not cubes:")
  n=1 count=0
  WHILE count<30
  DO
    sq=n*n
    IF IsCube(sq)=0 THEN
      PrintF("%I ",sq)
      count==+1
    FI
    n==+1
  OD
 
  PutE() PutE()
  PrintE("First 3 squares and cubes:")
  n=1 count=0
  WHILE count<3
  DO
    sq=n*n
    IF IsCube(sq) THEN
      PrintF("%I ",sq)
      count==+1
    FI
    n==+1
  OD
RETURN