题解 | #完全数计算#

完全数计算

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

def my_func(num):
    co = 0
    for i in range(1, int(num) + 1):
        res = []
        for k in range(1, i):
            if i % k == 0:
                res.append(k)
        if sum(res) == i:
            co += 1
    print(co)


while True:
    try:
        my_func(input())
    except (EOFError, KeyboardInterrupt):
        break
全部评论

相关推荐

评论
1
收藏
分享

创作者周榜

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