Pagini recente » Cod sursa (job #1160225) | Cod sursa (job #2814342) | Cod sursa (job #1735578) | Cod sursa (job #1863816) | Cod sursa (job #252916)
Cod sursa(job #252916)
var f,g:text;
s:array[1..2000000] of boolean;
n,i,k,nr:longint;
begin
assign(f,'ciur.in'); reset(f);
assign(g,'ciur.out'); rewrite(g);
readln(f,n);
nr:=n-1;
fillchar(s,sizeof(s),true);
for i:=2 to trunc(sqrt(n)) do
if s[i]=true then
begin
k:=i+i;
while k<=n do
begin
if s[k]=true then dec(nr);
s[k]:=false;
k:=k+i;
end;
end;
writeln(g,nr);
close(g);
end.