Cod sursa(job #352327)

Utilizator andrey932Andrei andrey932 Data 1 octombrie 2009 11:35:34
Problema Ciurul lui Eratosthenes Scor 100
Compilator fpc Status done
Runda Arhiva educationala Marime 0.44 kb
var t:text;
    i,j,n,nr:longint;
    var x:array[0..2000000] of boolean;

begin
assign(t,'ciur.in'); reset(t);
readln(t,n); close(t);
assign(t,'ciur.out'); rewrite(t);
x[1]:=true;
nr:=0;
for i:=2 to n do
  begin
    if x[i]=false then
      begin
        inc(nr);
        j:=2;
        while j*i<=n do
          begin
            x[j*i]:=true;
            inc(j);
          end;
      end;
  end;
writeln(t,nr);
close(t);
end.