from functools import reduce
def sum(a,b):
return a+b
for iin range(2,1001):
l = [1]
for jin range(2,int(i/2+1)):
if i%j ==0:
l.append(j)
if i == reduce(sum,l):
print(i)
print(l)
from functools import reduce
def sum(a,b):
return a+b
for iin range(2,1001):
l = [1]
for jin range(2,int(i/2+1)):
if i%j ==0:
l.append(j)
if i == reduce(sum,l):
print(i)
print(l)
本文标题:Python 一个数如果恰好等于它的因子之和,这个数就称为"完数
本文链接:https://www.haomeiwen.com/subject/oogjlftx.html
网友评论