program perfecte;
var n, num, suma, gasit, j:integer;
begin
write('n= '); read(n);
gasit:=0; num:=6;
writeln('numere perfecte de la 1 la n: ');
while (num<=n) do
begin
suma:=0;
for j:=1 to (num div 2) do
if (num mod j =0) then suma:=suma+j;
if (suma=num) then begin gasit:=1; write(num, ' '); end;
num:=num+2;
end;
if (gasit=0) then writeln('nu exista...');
writeln;
end.