Cod sursa(job #410825)
| Utilizator | Data | 4 martie 2010 16:51:04 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 30 |
| Compilator | fpc | Status | done |
| Runda | Arhiva educationala | Marime | 0.59 kb |
const tfi='ciur.in';
tfo='ciur.out';
maxn=2000005;
var fi,fo:text;
cnt, i,j,n:longint;
dd:array[0..maxn] of longint;
begin
assign(fi,tfi); reset(fi);
assign(fo,tfo); rewrite(fo);
read(fi,n);
for i:=2 to trunc(sqrt(n)) do
if dd[i]=0 then
begin
j:=i;
while i+j<=n do
begin
j:=i+j; dd[j]:=1;
end;
end;
j:=0;
for i:=2 to n do
if dd[i]=0 then inc(j);
writeln(fo,j);
close(Fi); close(fo);
end.