Chương trình chuẩn như sau:
Code:
program Tim_so_hoan_hao;
uses Crt;
const
max = 1000;
var
N, i, sum, mark : integer;
BEGIN
clrscr;
writeln('Cac so hoan hao <1000 la : ');
for N:=1 to max do
begin
sum := 0;
mark := 0;
for i:=(N div 2) downto 1 do
begin
if (N mod i = 0) then sum := sum + i;
if sum>=N then
begin
mark := i;
break;
end;
end;
if mark=1 then writeln(N);
end;
readln;
END.