Cod sursa(job #150584)
Utilizator | Ungur Richard-Alex Richi | Data | 7 martie 2008 07:50:17 |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 0 |
Compilator | fpc | Status | done |
Runda | Arhiva educationala | Marime | 0.45 kb |
var v:array[1..2000000] of byte;
n,i,j,k:longint;
begin
assign(input,'ciur.in'); reset(input);
assign(output,'ciur.out'); rewrite(output);
read(n);
for i:=2 to trunc(sqrt(n)) do
if v[i]=0 then begin for j:=2 to n div i do begin v[i*j]:=1;
j:=0;
writeln(k);
for i:=n downto 2 do
if v[i]=0 then begin
inc(j); k:=i;
if j=100 then break;
end;
writeln(j);
for i:=k to n do if v[i]=0 then write(i,' ');
close(input); close(output);
end.