Cod sursa(job #733197)

Utilizator ZancrowAugustin Zancrow Data 11 aprilie 2012 16:32:36
Problema Ciurul lui Eratosthenes Scor 100
Compilator fpc Status done
Runda Arhiva educationala Marime 0.49 kb
type tablou=array[1..2000000] of boolean;

var a:tablou;
    i,j,n,s:longint;
    f,h:text;
    
begin
assign(f,'ciur.in');
reset(f);
readln(f,n);
for i:=2 to n do a[i]:=true;
 for i:=2 to round(sqrt(n)) do
    if a[i] then
    begin
      j:=i;
      while j+i<=n do
      begin
        j:=j+i;
        a[j]:=false;
        end;
        end;
        assign(h,'ciur.out');
        rewrite(h);
for i:=2 to n do if a[i] then s:=s+1;
writeln(h,s);
close(f);
close(h);
end.