uses crt;
var n,t,i:integer;
begin
clrscr;
write('n='); readln(n);
t:=0;
for i:=1 to n-1 do
if n mod i=0 then t:=t+i;
if t=n then writeln(n,' la so hoan hao')
else writeln(n,' khong la so hoan hao');
readln;
end.
program shh;
uses crt;
var n,i,s:integer;
function shh(n:integer):boolean;
var i,s:integer;
begin
shh:=false;
s:=0;
for i:=1 to n div 2 do
if n mod i=0 then s:=s+i;
if s=n then shh:=true;
end;
begin
clrscr;
write('nhap n:');readln(n);
if shh(n) then writeln(n,' la so hoan hao')
else writeln(n,' ko la so hoan hao');
readln
end.
XONG RÙI ĐÓ
program sohoanhao;
uses crt;
var i,s,n:integer;
function sh(n:integer):boolean;
var i,s:integer;
begin
shh:=false;
s:=0;
for i:=1 to n div 2 do
if n mod i=0 then s:=s+i;
if s=n then shh:=true;
end;
begin
clrscr;
write('nhap n:');readln(n);
if shh(n) then writeln(n,' la so hoan hao')
else writeln(n,' ko la so hoan hao');
readln
end.