Exemple #1
0
from lib import find_all_factors

list = [0] * 10000

# initialize list
for i in range(10000):
    list[i] = sum(find_all_factors(i + 1)) - i - 1
print list[219], list[283]

# check amicable numbers
sumup = 0
for i in range(10000):  # the actual number is i+1
    j = list[i]
    if j - 1 in range(10000) and list[j - 1] == i + 1 and i + 1 != j:
        sumup += i + 1
        print i, j
print sumup
Exemple #2
0
from lib import find_all_factors

list = [0] * 10000

# initialize list
for i in range(10000):
    list[i] = sum(find_all_factors(i+1))-i-1
print list[219], list[283]

# check amicable numbers
sumup = 0
for i in range(10000): # the actual number is i+1
    j = list[i]
    if j-1 in range(10000) and list[j-1] == i+1 and i+1!=j:
        sumup +=i+1
        print i,j
print sumup
Exemple #3
0
#28123
from lib import find_all_factors
abundant_list = []
for i in range(28124):
    if sum(find_all_factors(i+1))-i-1>i+1:
        abundant_list.append(i+1)


list_len = len(abundant_list)
print list_len

list_two_abundant_sum_list = []
for i in range(list_len):
    for j in range(i,list_len):
        abundant_sum = abundant_list[i]+abundant_list[j]
        if abundant_sum < 28124: list_two_abundant_sum_list.append(abundant_sum)

print 28123*(1+28123)/2 - sum(list(set(list_two_abundant_sum_list)))
Exemple #4
0
#28123
from lib import find_all_factors
abundant_list = []
for i in range(28124):
    if sum(find_all_factors(i + 1)) - i - 1 > i + 1:
        abundant_list.append(i + 1)

list_len = len(abundant_list)
print list_len

list_two_abundant_sum_list = []
for i in range(list_len):
    for j in range(i, list_len):
        abundant_sum = abundant_list[i] + abundant_list[j]
        if abundant_sum < 28124:
            list_two_abundant_sum_list.append(abundant_sum)

print 28123 * (1 + 28123) / 2 - sum(list(set(list_two_abundant_sum_list)))