Program SNT; Uses crt; Var n: longint; Function SNT(a:longint):boolean; Var i:longint; Begin If i<2 then exit(false); For i:=2 to a div 2 do If a mod i = 0 then exit(false); exit(true); End;
Begin Clrscr; Write(‘Nhap N: ‘); Readln(n); If SNT(n) then Write(n,’ la so nguyen to’) Else Write(n,’ khong phai la so nguyen to’); Readln End.
program hotboy;
uses crt;
var n,i : integer;
kt: boolean;
begin
kt:=true;
write(‘nhap so can xet’); readln(n);
for i:=2 to n-1 do
if n mod i =0 then kt:=false;
if kt then write(n,’la so nguyen to)
else write(n,’khong phai la mot so nguyen to’);
readln
end.
Program SNT;
Uses crt;
Var n: longint;
Function SNT(a:longint):boolean;
Var i:longint;
Begin
If i<2 then exit(false);
For i:=2 to a div 2 do
If a mod i = 0 then exit(false);
exit(true);
End;
Begin
Clrscr;
Write(‘Nhap N: ‘); Readln(n);
If SNT(n) then Write(n,’ la so nguyen to’)
Else Write(n,’ khong phai la so nguyen to’);
Readln
End.