def fullnum(x,y):
int(x)
int(y)
List_1=[]
List_2=[]
for a in range(x,y+1):
m=0
n=0
for i in range(1,a):
if(a%i==0):
m+=i
if(m<=y and m>=x):
for i in range(1,m):
if(m%i==0):
n+=i
if(n==a and m!=a):
if(m<a):
m,a=a,m
List_1.append(a)
List_1.append(m)
if(List_1 not in List_2):
List_2.append(List_1)
List_1=[]
if(len(List_2)==1):
print("There are",len(List_2),"pair of Numbers from",x,"to",y)
else:
print("There are",len(List_2),"pairs of Numbers from",x,"to",y)
for i in List_2:
print(i)
print("Please enter the starting point and destination,separate them by comma")
x,y=eval(str(input()))
fullnum(x,y)
python-指定范围内的互满数
最新推荐文章于 2023-07-04 21:30:00 发布
本文介绍了一个用于寻找特定范围内完全数对的Python程序。完全数对是指两个数中每一个数都是另一个数的真因数之和,且这两个数不相等。文章通过一个具体的程序实例展示了如何遍历指定范围内的整数并找出所有符合条件的完全数对。

4277

被折叠的 条评论
为什么被折叠?



