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.




squareNotCube: procedure options(main);
 
    square: procedure(n) returns(fixed);
        declare n fixed;
        return(n * n);
    end square;
 
    cube: procedure(n) returns(fixed);
        declare n fixed;
        return(n * n * n);
    end cube;
 
    declare (ci, si, seen) fixed;
 
    ci = 1;
    do si = 1 repeat(si + 1) while(seen < 30);
        do while(cube(ci) < square(si));
            ci = ci + 1;
        end;
        if square(si) ^= cube(ci) then do;
            put edit(square(si)) (F(5));
            seen = seen + 1;
            if mod(seen,10) = 0 then put skip;
        end;
    end;
end squareNotCube;