Pagini recente » Cod sursa (job #2414392) | Cod sursa (job #552183) | Cod sursa (job #713782) | Cod sursa (job #1806130) | Cod sursa (job #1004855)
program ciurulluierathostenes;
var v:array[1..2000000] of boolean;
nr,i,j,n:longint;
f:text;
begin
assign(f,'ciur.in'); reset(f);
readln(f,n);
close(f);
assign(f,'ciur.out'); rewrite(f);
i:=3;
while i<=n do begin
v[i]:=true;
inc(i,2);
end;
nr:=1;
i:=3;
while (i<=trunc(sqrt(n))) do begin
j:=i+i;
while j<=n do begin
v[j]:=false;
inc(j,i);
end;
inc(i);
end;
for i:=3 to n do
if v[i] then inc(nr);
writeln(f,nr);
close(f);
end.