Cod sursa(job #422359)
Utilizator | yonootz321 C0Mr4d3 | Data | 22 martie 2010 16:15:14 |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 100 |
Compilator | fpc | Status | done |
Runda | Arhiva educationala | Marime | 0.46 kb |
program ciur;
var a:array[1..2000000] of boolean;
n,i,b,c:longint;
f:text;
begin
assign(f,'ciur.in');
reset(f);
read(f,n);
close(f);
for i:=2 to n do
a[i]:=true;
c:=0;
for i:=2 to n do
if a[i] then
begin
b:=i+i;
c:=c+1;
while b<=n do
begin
a[b]:=false;
b:=b+i;
end;
end;
assign(f,'ciur.out');
rewrite(f);
write(f,c);
close(f);
end.