题解 | #完全数计算#
完全数计算
https://www.nowcoder.com/practice/7299c12e6abb437c87ad3e712383ff84
n = int(input()) c = 0 for k in range(1,n+1): # 所有的n sum = 0 for i in range(1,int(k/2)+1): # 所有的因子只取一半 if k % i == 0: sum += i if sum == k: c += 1 print(c)
完全数计算
https://www.nowcoder.com/practice/7299c12e6abb437c87ad3e712383ff84
n = int(input()) c = 0 for k in range(1,n+1): # 所有的n sum = 0 for i in range(1,int(k/2)+1): # 所有的因子只取一半 if k % i == 0: sum += i if sum == k: c += 1 print(c)
相关推荐