Cod sursa(job #149507)
Utilizator | Data | 5 martie 2008 20:11:07 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 0 |
Compilator | fpc | Status | done |
Runda | Arhiva educationala | Marime | 0.46 kb |
type vec=array[1..2000000] of integer;
var v:vec;
n,i,k:longint;
procedure ciur;
var i,j:longint;
begin
k:=0;
for i:=2 to n do
if v[i]=0 then
begin
inc(k);
j:=i+i;
while j<=n do
begin
v[j]:= 1;
j:=j+i;
end;
end;
end;
begin {main}
assign(input,'ciur.in');reset(input);
assign(output,'ciur.out');rewrite(output);
read(n);
ciur;
writeln(k);
for i:=2 to n do
if v[i]=0 then write(i,' ');
end.