Cod sursa(job #155374)
Utilizator | Data | 11 martie 2008 21:37:01 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 20 |
Compilator | fpc | Status | done |
Runda | Arhiva educationala | Marime | 0.42 kb |
var i,j,n,cnt:integer;
v:array[1..20000] of integer;
f,g:text;
begin
cnt:=0;
assign(f,'ciur.in');reset(f);
assign(g,'ciur.out');rewrite(g);
read(f,n);
for i:=2 to trunc(sqrt(n)) do
if v[i]=0 then begin
for j:=2 to (n div i) do
v[i*j]:=1;
end;
for i:=2 to n do
if v[i]=0 then inc(cnt);
write(g,cnt);
close(f);
close(g);
end.