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.




int  C, N, N2, T;
[C:= 0;  N:= 1;
loop    [N2:= N*N;
        IntOut(0, N2);
        T:= fix(Pow(float(N2), 1./3.));
        if T*T*T # N2 then
                [ChOut(0, ^ );
                C:= C+1;
                if C >= 30 then quit;
                ]
        else    Text(0, "* ");
        N:= N+1;
        ];
Text(0, "^m^j* are both squares and cubes.^m^j");
]