Lời giải :
program hotrotinhoc;
var N,i : longint;
function NT(x: longint): boolean;
var i : longint;
begin
NT:=false;
if x<2 then exit;
for i:=2 to trunc(sqrt(x)) do
if x mod i=0 then exit;
NT:=true;
end;
Begin
write('N='); Readln(N);
if NT(N) then write('So nguyen to') else write('Khong phai so nguyen to');
readln
end.
uses crt;
var n:integer;
{----------chuong-trinh-con------------}
function ktra(a:integer):integer;
var kt,i:integer;
begin
kt:=0;
for i:=2 to trunc(sqrt(a)) do
if a mod i=0 then kt:=1;
if kt=0 then ktra:=0
else ktra:=1;
end;
{------------chuong-trinh-chinh-----------}
begin
clrscr;
write('nhap n='); readln(n);
if ktra(n)=0 then write(n,' la so nguyen to')
else write(n,' la hop so');
readln;
end.