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.




MODULE SquareNotCube;
FROM InOut IMPORT WriteString, WriteCard, WriteLn;
 
CONST   
    Amount = 30;
VAR     
    CubeRoot, SquareRoot, 
    Cube, Square,
    Seen: CARDINAL;
 
BEGIN
    Seen := 0;
    SquareRoot := 1;
    CubeRoot := 1;
    Square := 1;
    Cube := 1;
 
    REPEAT
        SquareRoot := SquareRoot + 1;
        Square := SquareRoot * SquareRoot;
        WHILE Square > Cube DO
            CubeRoot := CubeRoot + 1;
            Cube := CubeRoot * CubeRoot * CubeRoot;
        END;
        IF Square # Cube THEN
            Seen := Seen + 1;
            WriteCard(Square, 4);
            WriteLn();
        END;
    UNTIL Seen = Amount
END SquareNotCube.