Cod sursa(job #606685)
Utilizator | Data | 8 august 2011 03:11:19 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 0 |
Compilator | fpc | Status | done |
Runda | Arhiva educationala | Marime | 0.49 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:=2;
for i:=p to n do
if T[i]=0 then
begin
x:=i*i;
while x<=n do
begin
T[x]:=1;
inc(nr);
x:=x+i;
end;
end;
nr:=n-nr;
writeln(f2,nr);
close(f1); close(f2);
end.