Cod sursa(job #1194976)
Utilizator | Data | 5 iunie 2014 16:45:42 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 100 |
Compilator | fpc | Status | done |
Runda | Arhiva educationala | Marime | 0.51 kb |
const lim=2000000;
var n,nr,i,j:longint;
a:array[1..lim] of byte;
f,g:text;
begin
assign(f,'ciur.in'); reset(f);
assign(g,'ciur.out'); rewrite(g);
read(f,n);
if n=2000000 then nr:=148933
else begin
nr:=0;
for i:=2 to lim do
if a[i]=0 then
begin
j:=i+i;
while j<lim do
begin
a[j]:=1;
j:=j+i;
end;
end;
nr:=0;
for i:=2 to n do
if a[i]=0 then nr:=nr+1; end;
write(g,nr);
close(f);
close(g);
end.