uses crt; var n,i:longint; function hh(a:longint):boolean; var i,s:longint; begin hh:=true; s:=0; for i:=1 to a div 2 do if a mod i=0 then inc(s,i); if s<>a then hh:=false; end; begin clrscr; write(‘Nhap n: ‘); readln(n); writeln(‘Cac so hoan hao be hon ‘,n,’: ‘); for i:=1 to n-1 do if hh(i) then write(i,’ ‘); writeln; readln end.
var n,i,s:integer;
begin
write(‘Nhap n: ‘);readln(n);
for i:=1 to n-1 do if n mod i=0 then s:=s+i;
if n=s then writeln(‘Day la so hoan hao’) else writeln(‘Day khong phai la so hoan hao’);
readln
end.
uses crt;
var n,i:longint;
function hh(a:longint):boolean;
var i,s:longint;
begin
hh:=true; s:=0;
for i:=1 to a div 2 do
if a mod i=0 then inc(s,i);
if s<>a then hh:=false;
end;
begin
clrscr;
write(‘Nhap n: ‘); readln(n);
writeln(‘Cac so hoan hao be hon ‘,n,’: ‘);
for i:=1 to n-1 do
if hh(i) then write(i,’ ‘); writeln;
readln
end.