Program HOC24;
var i,n: integer;
function nt(x: longint): boolean;
var j: longint;
begin
nt:=true;
if (x=2) or (x=3) then exit;
nt:=false;
if (x=1) or (x mod 2=0) or (x mod 3=0) then exit;
j:=5;
while j<=trunc(sqrt(x)) do
begin
if (x mod j=0) or (x mod (j+2)=0) then exit;
j:=j+6;
end;
nt:=true;
end;
begin
write('Nhap N: '); readln(n);
write('Cac uoc nguyen to cua ',n,' la: ');
for i:=1 to n do if (n mod i=0) and nt(i) then write(i,' ');
readln
end.
Đúng 2
Bình luận (0)