问题描述:
用pascal求2到1000的亲密数对
program zlx;
var
n1,n2,a,b,s1,s2:integer;
begin
writeln;
for n1:=2 to 1000 do
begin
s1:=0;
for a:=1 to n1-1 do
if n1 mod a=0 then
begin
s1:=s1+a;
for n2:=2 to 1000 do
begin
s2:=0;
for b:=1 to n2-1 do
if n2 mod b=0 then
begin
s2:=s2+b;
if (s1=n2) and (s2=n1) and (n1
program zlx;
var
n1,n2,a,b,s1,s2:integer;
begin
writeln;
for n1:=2 to 1000 do
begin
s1:=0;
for a:=1 to n1-1 do
if n1 mod a=0 then
begin
s1:=s1+a;
for n2:=2 to 1000 do
begin
s2:=0;
for b:=1 to n2-1 do
if n2 mod b=0 then
begin
s2:=s2+b;
if (s1=n2) and (s2=n1) and (n1
问题解答:
我来补答展开全文阅读