Cod sursa(job #602499)
Utilizator | UAIC.VlasCatalin ctlin04 | Data | 11 iulie 2011 17:50:31 |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 30 |
Compilator | fpc | Status | done |
Runda | Arhiva educationala | Marime | 0.59 kb |
program ciurul;
var n,i,j,k:longint;
a:array [1..2000000] of longint;
fi,fo:text;
begin
assign(fi,'ciur.in');
reset(fi);
assign(fo,'ciur.out');
rewrite(fo);
read(fi,n);
for i:=1 to n do a[i]:=i;
for i:=2 to n div 2 do begin
j:=2*i;
while j<=n do begin
if a[j]<>0 then a[j]:=0;
j:=j+i;
end;
end;
for i:=2 to n do
if a[i]<>0 then inc(k);
write(fo,k);
close(fo);
end.