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.




square_not_cube = iter () yields (int)
    cube_root: int := 1
    square_root: int := 1
 
    while true do 
        while cube_root ** 3 < square_root ** 2 do
            cube_root := cube_root + 1
        end
        if square_root ** 2 ~= cube_root ** 3 then
            yield(square_root ** 2)
        end
        square_root := square_root + 1
    end
end square_not_cube
 
start_up = proc ()
    amount = 30
    po: stream := stream$primary_output()
    n: int := 0
 
    for i: int in square_not_cube() do
        stream$putright(po, int$unparse(i), 5)
        n := n + 1
        if n // 10 = 0 then stream$putl(po, "") end
        if n = amount then break end
    end
end start_up