题解 | #完全数计算#

完全数计算

http://www.nowcoder.com/practice/7299c12e6abb437c87ad3e712383ff84

n = int(input()) start = 1 count = 0 out = []

which = []

for i in range(2, n + 1): while True: if i % start == 0: out.append(start) if i == start: start = 1 #,重置start,重新计算 break start += 1 if sum(out[0:-1]) == out[-1]: count += 1 # which.append(out[-1]) #输出完全数 out.clear() #清空out,重新计算 print(count)

全部评论

相关推荐

03-03 19:02
已编辑
东华理工大学 Node.js
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务