Cod sursa(job #144644)
| Utilizator | Data | 27 februarie 2008 20:29:01 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 0 |
| Compilator | fpc | Status | done |
| Runda | Arhiva educationala | Marime | 0.65 kb |
var n,i,j,nr:longint;
v:array[1..2000001] of byte;
begin
assign(input,'ciur.in');reset(input);
assign(output,'ciur.out');rewrite(output);
readln(n);
for i:=2 to trunc(sqrt(n)) do
for j:=2 to n div i do
v[i*j]:=1;
for i:=2 to n do
if v[i]=0 then
inc(nr);
writeln(nr);
for i:=n downto 2 do
begin
if v[i]=0 then
dec(nr);
if nr=0 then
begin
nr:=i;
break;
end;
end;
for i:=nr to n do
if v[i]=0 then
write(i,' ');
writeln;
close(input);close(output);
end.