Cod sursa(job #604930)
| Utilizator | Data | 26 iulie 2011 02:03:57 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 30 |
| Compilator | fpc | Status | done |
| Runda | Arhiva educationala | Marime | 0.47 kb |
program ciur;
var
n,i,count,j:longint;
v:array[1..2000000] of boolean;
f,g:text;
begin
assign(f,'ciur.in');
assign(g,'ciur.out');
reset(f);
read(f,n);
close(f);
for i:=2 to n do
begin
if (not v[i]) and (i<=round(sqrt(n))) then
begin
inc(count);
for j:=i+1 to n do
if j mod i=0 then
v[j]:=true;
end;
if (not v[i]) and (i>round(sqrt(n))) then
inc(count);
end;
rewrite(g);
write(g,count);
close(g);
end.