Cod sursa(job #614292)

Utilizator KennedyKennedy Kennedy Data 5 octombrie 2011 22:12:31
Problema Ciurul lui Eratosthenes Scor 70
Compilator fpc Status done
Runda Arhiva educationala Marime 0.35 kb
Program Ciur;
type Numar=0..2000000;
var f:text;
    d:array[2..2000000] of boolean;
    i,j,n,k:Numar;
begin
    assign(f,'ciur.in'); reset(f); readln(f,n); close(f);
    k:=0;
    for i:=2 to n do if not(d[i]) then begin for j:=2 to n div i do d[i*j]:=true; k:=k+1; end;
    assign(f,'ciur.out'); rewrite(f);
    write(f,k);
    close(f);
end.