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("不是完数")
2024-01-22 10:27:28
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("不是完数")