uses crt; var n,i,d:longint; function nt(a:longint):boolean; var i:longint; begin i:=2; while(a>1)and(a mod i<>0)do inc(i); nt:=i=a; end; begin clrscr; write(‘Nhap n: ‘); readln(n); for i:=1 to n do if nt(i) then inc(d); writeln(‘Ket qua: ‘,d); readln end.
Uses crt;
var i,n,dem,tong,j:Integer;
Begin
ClrScr;
write(‘Nhap so nguyen duong n’);ReadLn(n);
dem:=0;
for j:=1 to n do begin
for i:= 1 to j do if j mod i=0 then dem:=dem+1;
if (j>=2) and (dem=2) then tong:=tong+1;
dem:=0;
end;
writeln(‘Co ‘,tong,’ so nguyen to ‘);
Readln
End.
uses crt;
var n,i,d:longint;
function nt(a:longint):boolean;
var i:longint;
begin
i:=2;
while(a>1)and(a mod i<>0)do inc(i);
nt:=i=a;
end;
begin
clrscr;
write(‘Nhap n: ‘); readln(n);
for i:=1 to n do
if nt(i) then inc(d);
writeln(‘Ket qua: ‘,d);
readln
end.