题解 | #完全数计算#
完全数计算
http://www.nowcoder.com/practice/7299c12e6abb437c87ad3e712383ff84
定义函数来做更简单明了,但还是要注意变量名的取法
while True:
try:
n = int(input())
out = 0
def n_sum(a):
res = 0
for i in range(1,a):
if a%i ==0:
res+=i
return res
for i in range(1,n+1):
if i==n_sum(i):
out+=1
print(out)
except:break