Cod sursa(job #146961)

Utilizator loriKis Levente Lorand lori Data 2 martie 2008 14:14:16
Problema Ciurul lui Eratosthenes Scor 0
Compilator fpc Status done
Runda Arhiva educationala Marime 0.43 kb
var v:array [1..2000000] of integer;
    n,i,j,k:longint;
begin
 assign(input,'ciur.in'); reset(input);
 assign(output,'ciur.out'); rewrite(output);
  readln(n);
  for i:=2 to n do
   if v[i]=0 then begin
    inc(k);
    for j:=2  to n div i do v[i*j]:=1;
   end;
  writeln(k); j:=0; k:=k-1000;
  for i:=2 to n do
   if v[i]=0 then begin
    inc(j);
    if j>k then write(i,' ');
   end;
 close(input); close(output);
end.