Cod sursa(job #869851)

Utilizator rotarraresRotar Rares rotarrares Data 2 februarie 2013 14:09:45
Problema Ciurul lui Eratosthenes Scor 30
Compilator fpc Status done
Runda Arhiva educationala Marime 0.44 kb
Program eratosthenes;

var a:array[2..2000000] of boolean;j,n:longint;i,x:integer;
f,g:text;
Begin
assign(f,'ciur.in');reset(f);
assign(g,'ciur.out');rewrite(g);
readln(f,n);
close(f);
For i:=2 to trunc(sqrt(n)) do
   If a[i]=false then
     Begin
     j:=2;
     repeat
        a[j*i]:=true;
        j:=j+1;
     until j*i>n;
     end;
x:=0;
For j:=2 to n do
If a[j]=false then
x:=x+1;
writeln(g,x);
close(g);
end.