Function ngto(a: qword): boolean; Var i: longint; Begin If a<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 ngto(n) then Write(‘YES’) Else Write(‘NO’); Readln End.
program ct;
uses crt;
var n,i:integer;
begin
clrscr;
write(‘nhap 1 so nguyen:=’);readln(n);
if n<=1 then writeln(n khong phai so nguyen to’) else
begin
i:=2;
while n mod i<>0 do i:=i+1;
if i=n then writeln(n,’ la so nguyen to’) else writeln(n,’ khong la so nguyen to’);
end;
readln
end.
Program FNG;
Uses crt;
Var n: qword;
Function ngto(a: qword): boolean;
Var i: longint;
Begin
If a<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 ngto(n) then Write(‘YES’)
Else Write(‘NO’);
Readln
End.