uses crt; Var i,n: integer; Begin Clrscr; Write (‘Nhap so can kiem tra n: ‘); readln(n); If (n=0) or (n=1) then Writeln(n,’ Khong phai la so nguyen to’) Else Begin i:=1; Repeat i:= i+1; Until (n mod i= 0) or (i*i>n); If i*i>n then Writeln (n,’ la so nguyen to’) Else Writeln (n,’ khong phai la so nguyen to’); End; Readln; End.
program kiemtra;
uses crt;
var n,i:integer;
kt:boolean;
begin
clrscr;
write(‘Nhap so can kiem tra: ‘); readln(n);
kt:=true;
if n<2 then kt:=false;
for i:=2 to trunc(sqrt(n)) do
if n mod i=0 then kt:=false;
if kt=true then write(n,’ la so nguyen to’)
else write(n,’ khong la so nguyen to’);
readln
end.
uses crt;
Var i,n: integer;
Begin
Clrscr;
Write (‘Nhap so can kiem tra n: ‘); readln(n);
If (n=0) or (n=1) then
Writeln(n,’ Khong phai la so nguyen to’)
Else
Begin
i:=1;
Repeat
i:= i+1;
Until (n mod i= 0) or (i*i>n);
If i*i>n then
Writeln (n,’ la so nguyen to’)
Else
Writeln (n,’ khong phai la so nguyen to’);
End;
Readln;
End.