Cod sursa(job #411077)

Utilizator axel15dobre alex axel15 Data 4 martie 2010 18:34:22
Problema Ciurul lui Eratosthenes Scor 20
Compilator fpc Status done
Runda Arhiva educationala Marime 0.45 kb
var  a:array[1..1000000000] of 0..1;
     f,g:text;
     i,j,b,nr,n,s,p:longint;
     x:char;
begin
assign(f,'ciur.in'); reset(f);
assign(g,'ciur.out'); rewrite(g); p:=1;
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
  for j:=2 to n do  begin
    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.