uses crt;
var n,t,i,kt,j,t1:integer;
begin
clrscr;
write('Nhap 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');
writeln('Cac so nguyen to trong khoang tu 2 toi ',n,' la: ');
for i:=2 to n do
begin
kt:=0;
for j:=2 to i-1 do
if i mod j=0 then kt:=1;
if kt=0 then write(i:4);
end;
writeln;
t1:=0;
for i:=2 to n do
t1:=t1+i;
writeln('Tong cac so trong khoang tu 2 toi ',n,' la: ',t1);
if sqrt(t1)=trunc(sqrt(t1)) then writeln(t1,' la so chinh phuong')
else writeln(t1,' khong la so chinh phuong');
readln;
end.