viet chuong trinh nhap vao 1 so N tu ban phim va kiem tra xem so do co phai la so nguyen to khong
0 bình luận về “viet chuong trinh nhap vao 1 so N tu ban phim va kiem tra xem so do co phai la so nguyen to khong”
uses crt; var i,N,dem:byte; begin Write(‘Nhap N :’);Readln(N); for i:=1 to N do if N mod i=0 then dem:=dem+1; if dem=2 then Write(N,’ la so nguyen to’) else Write(N,’khong phai la so nguyen to’); Readln End.
uses crt;
var i,N,dem:byte;
begin
Write(‘Nhap N :’);Readln(N);
for i:=1 to N do
if N mod i=0 then dem:=dem+1;
if dem=2 then Write(N,’ la so nguyen to’)
else Write(N,’khong phai la so nguyen to’);
Readln
End.
progra nguyen_to;
uses crt;
var n,i,d:integer;
begin
clrscr;
write(‘Nhap N: ‘); readln(n);
if n<2 then write(n,’ khong phai so nguyen to’)
else begin
d:=0;
for i:=1 to n do
if n mod i=0 then d:=d+1;
if d=2 then write(n,’ la so nguyen to’)
else write(n,’ khong phai so nguyen to’);
end;
readln;
end.