我的代码打印“6 24 24 24 24 28 496”。我不想要24s。我怎么解决这个问题?
program perfect;
uses crt;
var i,number,temp:integer;
begin
clrscr;
for number:=2 to 999 do begin
temp:=1;
for i:=2 to Trunc(number/2) do begin
if (number mod i = 0) then
temp:=temp+i;
if(temp=number) then
writeln(number);
end;
end;
readln;
end.