def highly_divisible_triangular_number(min_divisors):
    """
    finds a triangle number that number of divisors exceeds 'min_divisors'

    min_divisors (int): limit, inclusive
    returns (int): triangle number
    """
    for tri_number in gen_triangular_number():
        if len(get_divisors(tri_number)) > min_divisors:
            return tri_number
Beispiel #2
0
def sum_of_proper_divisors(num):
    """
    determines the sum of the proper divisors of some number e.g. proper
    divisors of 284 are 1, 2, 4, 71, 142 ==> 220

    num (int): number > 1
    returns (int): sum
    """
    divisors = get_divisors(num)
    divisors.remove(num)
    return sum(divisors)    
Beispiel #3
0
def sum_of_proper_divisors(num):
    """
    determines the sum of the proper divisors of some number e.g. proper
    divisors of 284 are 1, 2, 4, 71, 142 ==> 220

    num (int): number > 1
    returns (int): sum
    """
    assert num >= 1
    if num == 2:
        return 1
    else:
        return sum(get_divisors(num)[:-1])
Beispiel #4
0
import argparse
import math
import euler
import sets

if __name__ == '__main__':
    parser = argparse.ArgumentParser(description = 'Solves problem number 19 of Euler Project')
    parser.add_argument('--limit', type=int, default=28123)
    args = parser.parse_args()

    abundant = []

    for number in range(1, args.limit):
        sum_div = sum(euler.get_divisors(number))
        if sum_div > number:
            abundant.append(number)

    sum_set = sets.Set()
    for pos, first in enumerate(abundant): 
        for second in abundant[pos:]:
            if first+second<args.limit:
                sum_set.add(first+second)

    total = 0
    for number in range(1, args.limit):
        if number not in sum_set:
            total += number
    
    print total