编程输出1~10000内所有的完全数(如6)即真因子之和都等于他本身的数用pascal repea...

2024-12-25 22:49:40
推荐回答(2个)
回答1:

var
s,i,j:integer;

begin
for i:=1 to 10000 do
begin
s:=0;
for j:=1 to i-1 do
if (i mod j)=0 then s:=s+j;
if s=i then write(i:5);
end;
end.

回答2:

var
ans,i,j:integer;
begin
for i:=1 to 10000 do begin
ans:=0;
for j:=1 to i-1 do
if i mod j=0 then s:=s+j;
if s=i then writeln(i);
end;
end.