Cod sursa(job #209277)
| Utilizator | Data | 21 septembrie 2008 18:44:15 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 30 |
| Compilator | fpc | Status | done |
| Runda | Arhiva educationala | Marime | 0.43 kb |
program pascal;
var f,g:text;
i,d,n,nr,rez,j:longint;
v:array[1..2000000] of longint;
begin
assign(f,'ciur.in'); reset(f);
assign(g,'ciur.out'); rewrite(g);
read(f,n);
rez:=0;
for d:=2 to trunc(sqrt(n)) do
if v[d]=0 then
begin
for j:=2 to n div d do v[d*j]:=1;
end;
for i:=2 to n do
if v[i]=0 then inc(rez);
write(g,rez);
close(f);
close(g);
end.
