I'm currently writing a code the takes a number given a prints all the prime numbers that fit the format 4n+1. This is what I have so far. They problem is that this gives me a runtime error 207 which I think means invalid floating point operation, but I can't see how it ended up doing an invalid floating point operation. The only the code should be dealing with negative numbers in the line "if num-(iter*iter)> then".
program TwoSquares;
var
num, numSqrt, iter, bigSqr,smallSqr: integer;
begin
num:=29;
while num>4 do
begin
numSqrt:=trunc(sqrt(num));
for iter:=2 to numSqrt do
begin
if num mod iter = 0 then
num:=num - 1;
continue;
end;
if (num-1) mod 4 = 0 then
begin
iter:=(num-1) div 4;
while iter>0 do
begin
if num-(iter*iter)>0 then
bigSqr:=iter;
break;
iter:=iter-1;
end;
smallSqr:=trunc(sqrt(num-(iter*iter)));
writeln(num,' ', smallSqr,' ',bigSqr);
num:=num - 1;
end;
end;
end.