Пример #1
0
#!python
from pelib import sum_of_proper_divisors

if __name__ == '__main__':
            
    sums_dict = dict()
    for i in range(1,10000): sums_dict[i] = sum_of_proper_divisors(i)

    sum = 0
    for i in range(1,10000):
        if sums_dict[i] != i and \
        sums_dict[i] > 0 and \
        sums_dict[i] < 10000 and \
        sums_dict[sums_dict[i]] == i:
            sum += i
            
    print "Sum: ", sum
    
    exit(0)
Пример #2
0
#!python
from pelib import sum_of_proper_divisors, Found

if __name__ == '__main__':	

    upper_bound = 28124
                
    even_abundants = [] #list of even abundant numbers
    odd_abundants = [] #list of odd abundant numbers
    for i in range(1,upper_bound):
        if sum_of_proper_divisors(i) > i:
            if i%2 == 0:
                even_abundants.append(i)
            else:
                odd_abundants.append(i)
            
    sum = 0
    for i in range(1,upper_bound):
        try:
            if i%2 == 0:
                #sum two things from odd_abundants
                for j in odd_abundants:
                    if j > i:
                        #no more possible matches, assuming odd_abundants is ascending
                        break
                    if i-j in odd_abundants:
                        raise Found
                #sum two things from even_abundants
                for j in even_abundants:
                    if j > i:
                        #no more possible matches, assuming even_abundants is ascending