Cod sursa(job #145209)
Utilizator | Mircea Radu-Viorel radupoint | Data | 28 februarie 2008 16:28:11 |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 0 |
Compilator | fpc | Status | done |
Runda | Arhiva educationala | Marime | 0.66 kb |
program ciur;
var
f:text;
n,i,j,k,a,x:longint;
ok:boolean;
v:array[1..10000] of longint;
begin
assign(f,'ciur.in');
reset(f);
read(f,n);
close(f);
assign(f,'ciur.out');
rewrite(f);
for i:=1 to n do
begin
ok:=true;
j:=2;
a:=i;
while (ok) and (j<=a div 2) do
begin
if a mod j=0 then
ok:=false;
inc(j);
end;
if (ok) and (i=a) then
begin
inc(k);
v[k]:=i;
inc(x);
end;
end;
writeln(f,x);
for k:=1 to x do
write(f,v[k],' ');
close(f);
end.