Cod sursa(job #289785)

Utilizator andreirulzzzUPB-Hulea-Ionescu-Roman andreirulzzz Data 26 martie 2009 23:31:36
Problema Ciurul lui Eratosthenes Scor 100
Compilator fpc Status done
Runda aa Marime 0.41 kb
program ciur;
var f:text;
    a:array[1..2000001] of byte;
    n,i,j,nr:longint;
begin
assign(f,'ciur.in');
reset(f);
read(f,n);
close(f);
nr:=0;            
for i:=2 to n do
    if a[i]=0 then begin
       inc(nr);
       j:=0;
       while (j+1)*i<=n do begin
             inc(j);
             a[i*j]:=1;
             end;
       end;
assign(f,'ciur.out');
rewrite(f);
write(f,nr);
close(f);
end.