Код: Выделить всё
function issimple(x:longint):boolean;
var i:longint;
begin
for i:=2 to trunc(sqrt(x)) do
if x mod i=0 then begin
issimple:=false;exit; end;
issimple:=true;
end;
Код: Выделить всё
function issimple(x:longint):boolean;
var i:longint;
begin
for i:=2 to trunc(sqrt(x)) do
if x mod i=0 then begin
issimple:=false;exit; end;
issimple:=true;
end;
Код: Выделить всё
function issimple (x:longint):boolean;
var i:longint;
begin
{ Особый случай: число 1 не относится к простым. }
{ Как, впрочем, не относится и к составным. }
if (x = 1) then begin
issimple := false;
exit;
end;
for i:=2 to Trunc (sqrt (x)) do
if x mod i=0 then begin
issimple:=false;exit; end;
issimple:=true;
end;