def wan(n):
sum = 0
i = 1
while i <= n - 1:
if n % i == 0:
sum += i
i += 1
if sum == n:
return True
else:
return False
wan = wan(int(input("请输入一个数:")))
if wan:
print("是完数")
else:
print("不是完数")
标签:wan,return,函数,sum,else,pyhton,完数,print
来源: https://www.cnblogs.com/ZhaoBa/p/14747146.html