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.




include "cowgol.coh";
 
var cube: uint16 := 1;
var ncube: uint16 := 1;
var sqr: uint16 := 1;
var nsqr: uint16 := 1;
 
var seen: uint8 := 0;
while seen < 30 loop
    sqr := nsqr * nsqr;
    while sqr > cube loop
        ncube := ncube + 1;
        cube := ncube * ncube * ncube;
    end loop;
    if sqr != cube then
        seen := seen + 1;
        print_i16(sqr);
        print_char(' ');
    end if;
    nsqr := nsqr + 1;
end loop;
print_nl();