def factor(n):
nums = [ ]
for i in range(1,n+1):
if n % i == 0:
nums.append(i)
print(n,"的因子有:",nums)
print("所有因子的和为: ",sum(nums))
while True:
num = int(input("请输入 100 到 1000 之间的数"))
if not 100 <= num <= 1000:
print("请输入正确数值")
continue
factor(num)
break
2020-06-07