Cod sursa(job #1191571)

Utilizator LyricalBoris Butnaru Lyrical Data 28 mai 2014 01:05:47
Problema Ciurul lui Eratosthenes Scor 30
Compilator fpc Status done
Runda Arhiva educationala Marime 0.46 kb
Program ciur;
type Vector = array [1..2000000] of boolean;
var t : Vector;
    n,i,j,x : integer;
    f : text;
begin
assign (f,'ciur.in');
reset(f);
read(f,n);
close(f);
i:=1;j:=1;
for i:=2 to n do t[i]:=true;

for i:=2 to n do
  begin
    if t[i] then
      begin
        for j:=2 to n div i do
          t[i*j]:=false;
      end;
  end;
x:=0;
for i:=2 to n do
    begin
    if t[i] then x:=x+1;
    end;
assign (f,'ciur.out');
rewrite(f);
write(f,x);
close(f);

end.