Pascal求N以内的完美数完全数(Perfect number),又称完美数或完备数,是一些特殊的自然数。它所有的真因子(即除了自身以外的约数)的和(即因子函数),恰好等于它本身。
program bill02; var m,n,y,i,j,s,ss,z:longint; a:array[1..10000] of integer; begin readln(m,n); for i:=m to n do begin z:=0; fillchar(a,sizeof(a),0); s:=2; ss:=1; y:=i; while y<>0 do begin if y mod s=0 then begin ss:=ss+1; a[ss]:=s; y:=y div s; end else s:=s+1; end; for j:=1 to ss do z:=z+a[j]; if z=i then writeln(i); end; end.