Cod sursa(job #607946)

Utilizator SpiritGanea Dinu Spirit Data 13 august 2011 23:01:29
Problema Ciurul lui Eratosthenes Scor 20
Compilator fpc Status done
Runda Arhiva educationala Marime 0.37 kb
Program Eratostene;
var T:array[1..2000] of 0..1;
    p,nr,i,j,n,x:longint;
    f1,f2:text;
begin
assign(f1,'ciur.in'); reset(f1);
assign(f2,'ciur.out'); rewrite(f2);
readln(f1,n);
p:=0;

for i:=2 to n div 2 do
 if T[i]=0 then
   for j:=2 to n div i do
     T[i*j]:=1;

for i:=1 to n do
 if T[i]=0 then inc(nr);
dec(nr);
writeln(f2,nr);
close(f1); close(f2);
end.