1.检查完全数和检查质数方式类似,因子不会超过 数字本身的平方根,减少遍历次数
当整除时候,将除数和商同时加入求和
2.由于为多行输入,直接把多行全部加入列表,取其中最大值,求一次完全数列表
3.查找个数的方法.当查找数,正好是完全数的时候,由于不超过,所以不计算,为完全数列表中,数值的索引。当不是完全数的时候,将数值插入列表,重排,查找索引位置,也为完全数个数
def perfect_num(num):        #检查是否为完全数
    res_num = 1
    for i in range(2,int(num**0.5)+1):
        if not num%i and i != num//i:
            res_num += i
            res_num += num//i
        elif not num%i:
            res_num += i
    if res_num == num:
        return True
    else:
        return False

while True:
    try:
        num_list = []        #输入列表
        _cache = []          #完全数缓存列表
        num_list.append(int(input()))
        for i in range(2,max(num_list)):
            if perfect_num(i):
                _cache.append(i)
        for j in num_list:
            if j in _cache:
                print(_cache.index(j))
            else:
                _cache.append(j)
                _cache = sorted(_cache)
                print(_cache.index(j))
    except:
        break