Pagini recente » Cod sursa (job #1211954) | Cod sursa (job #1588102) | Cod sursa (job #953660) | Cod sursa (job #2663208) | Cod sursa (job #493502)
Cod sursa(job #493502)
program ciurul_lui_eratostene;
const MAX=2000000;
var f,g:text; i,j,n,S:0..MAX; prim:array[1..MAX] of 0..1;
begin
Assign(f,'ciur.in'); Reset(f);
Assign(g,'ciur.out');Rewrite(g);
Read(f,n); Close(f); {prim: 1=da; 0=nu}
For i:=2 to n do prim[i]:=1;
S:=0;
For i:=2 to n do
If prim[i]=1 then
begin
For j:=1 to n div i do
prim[i*j]:=0;
inc(S);
end;
Write(g,S); Close(g);
end.