def problem():
    """ Attempt to solve the problem... """

    print 'problem #21'

    t = 0
    for a in xrange(1, 10000):
        b = sum(proper_divisors(a))
        if b != a and a == sum(proper_divisors(b)):
            t += a
    print 'the sum of amicable numbers is %s' % t
예제 #2
0
def perfect(n):
    if n < 1:
        raise ValueError

    s = sum(proper_divisors(n))

    if s < n:
        return -1
    elif s > n:
        return 1
    else:
        return 0
def problem():
    """ Attempt to solve the problem... """

    print 'problem #23'
    s = 0
    abundant_numbers = {}
    for x in xrange(1, 28123):
        d = proper_divisors(x)
        if sum(d) > x:
            abundant_numbers[x] = 0

        is_sum_found = False
        for i in abundant_numbers.keys():
            if abundant_numbers.get(x - i) is not None:
                is_sum_found = True
                break
        if not is_sum_found:
            s += x

    print 'the sum of all integers which cannot be written as the sum of two'\
          ' abundant numbers is %s' % s
예제 #4
0
def d(x):
    return (sum(proper_divisors(x)))
예제 #5
0
def abundant_numbers(limit):
    abundant_nums = []
    for n in xrange(1, limit):
        if sum(proper_divisors(n)) > n:
            abundant_nums.append(n)
    return abundant_nums