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.




 
program Square_but_not_cube;
 
{$APPTYPE CONSOLE}
 
uses
  System.SysUtils,
  System.Math;
 
begin
  var count := 0;
  var n := 1;
  while count < 30 do
  begin
    var sq := n * n;
    var cr := Trunc(Power(sq, 1 / 3));
    if cr * cr * cr <> sq then
    begin
      inc(count);
      writeln(sq);
    end
    else
      Writeln(sq, ' is square and cube');
    inc(n);
  end;
 
 {$IFNDEF UNIX}   readln; {$ENDIF}
end.