Cod sursa(job #431291)
| Utilizator | Data | 31 martie 2010 20:33:52 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 30 |
| Compilator | fpc | Status | done |
| Runda | Arhiva educationala | Marime | 0.56 kb |
var x,p,n,i:longword;
pd:array[1..2000000]of boolean;
begin
assign(input,'ciur.in');
assign(output,'ciur.out');
reset(input);
read(n);
close(input);
p:=0;
for i:=1 to n do
pd[i]:=true;
for i:=2 to n do
begin
if pd[i] then
begin
x:=i*i;
while x<=n do
begin
pd[x]:=false;
x:=x+i;
end;
end;
end;
for i:=2 to n do
if pd[i] then inc(p);
rewrite(output);
write(p);
close(output);
end.
