题解 | #完全数计算#
完全数计算
https://www.nowcoder.com/practice/7299c12e6abb437c87ad3e712383ff84
n = int(input())
count = 0
for i in range(1,n+1):
sum = 0
for j in range(1,int(i/2)+1):
if i % j == 0:
sum += j
if i == sum:
count += 1
print(count)
完全数计算
https://www.nowcoder.com/practice/7299c12e6abb437c87ad3e712383ff84
n = int(input())
count = 0
for i in range(1,n+1):
sum = 0
for j in range(1,int(i/2)+1):
if i % j == 0:
sum += j
if i == sum:
count += 1
print(count)
相关推荐