Cod sursa(job #800862)
Utilizator | Data | 22 octombrie 2012 20:26:14 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 100 |
Compilator | fpc | Status | done |
Runda | Arhiva educationala | Marime | 0.45 kb |
var f,g:text;
n,s,c,i:longint;
v:array[2..2000000] of byte;
begin
assign(f,'ciur.in');
assign(g,'ciur.out');
reset(f);
rewrite(g);
readln(f,n);
s:=0;
fillchar(v,sizeof(v),1);
for i:=2 to n do
if v[i]=1 then
begin
c:=i+i;
inc(s);
while c<=n do
begin
v[c]:=2;
inc(c,i);
end;
end;
writeln(g,s);
close(f);
close(g);
end.