Cod sursa(job #1036203)

Utilizator Vele_GeorgeVele George Vele_George Data 19 noiembrie 2013 01:06:09
Problema Ciurul lui Eratosthenes Scor 100
Compilator fpc Status done
Runda Arhiva educationala Marime 0.51 kb
var a:array[1..2000004] of byte;
    i,j,n,nr:longint;
    f:text;
begin
assign(f,'ciur.in');reset(f);
readln(f,n);close(f);
//for i:=1 to 2000000 do a[i]:=0;
for i:=2 to n do
 if a[i]=0 then begin
                 j:=i+i;
                 while j<=n do begin
                                a[j]:=1;
                                j:=j+i;
                               end;
                end;
assign(f,'ciur.out');rewrite(f);
for i:=2 to n do if a[i]=0 then inc(nr);
write(f,nr);close(f);


end.