Cod sursa(job #412978)

Utilizator axel15dobre alex axel15 Data 7 martie 2010 12:05:40
Problema Ciurul lui Eratosthenes Scor 30
Compilator fpc Status done
Runda Arhiva educationala Marime 0.47 kb
var  a:array[1..20000000] of integer;
     f,g:text;
     i,j,b,nr,n:longint;
     x:char;
begin
assign(f,'ciur.in'); reset(f);
assign(g,'ciur.out'); rewrite(g);
{while not eoln(f) do begin
read(f,x);
s:=ord(x)-ord('0');
n:=n*p+s;
p:=10;
   end;}
read(f,n);
for i:=2 to n do begin
 j:=1; b:=0;
  while (j<=n) and (b<=n) do  begin
    j:=j+1;
    b:=j*i;
    a[b]:=1;
  end; end;
for b:=2 to n do
if a[b]=0 then nr:=nr+1;
write(g,nr);
close(g);
close(f);
end.