题解 | #完全数计算#
完全数计算
https://www.nowcoder.com/practice/7299c12e6abb437c87ad3e712383ff84
def is_prefect(n):
m = int(n**0.5) + 1
sum_ti = 1
for i in range(2, m):
if n%i==0:
sum_ti+=i
sum_ti+= n//i
return sum_ti==n
inp = int(input())
if inp == 1:
print("0")
else:
ans = 0
for i in range(2, inp+1):
if is_prefect(i):
ans+=1
print(ans)