Cod sursa(job #579371)

Utilizator DDeidaraSzasz Tamas Csaba DDeidara Data 12 aprilie 2011 08:56:35
Problema Ciurul lui Eratosthenes Scor 0
Compilator fpc Status done
Runda Arhiva educationala Marime 0.52 kb
program ciur;
var n,i,count,j:longint;x:array[1..2000000] of boolean;f:text;
begin
        assign(f,'ciur.in');
        reset(f);
        readln(f,n);
        close(f);
        for i:=2 to n do if x[i]=false then begin
                j:=2;
                while j*i<n do begin
                        x[j*i]:=true;
                        j:=j+1;
                        end;
                end else count:=count+1;
        assign(f,'ciur.out');
        rewrite(f);
        writeln(f,count);
        close(f);
end.