RosettaCodeData/Task/Square-but-not-cube/Delphi/square-but-not-cube.delphi

28 lines
415 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
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.