Example #1
0
def eul32():
    """"Find the sum of all products whose multiplicand/multiplier/product identity can be written as a
    1 through 9 pandigital."""
    products = set()
    for product in range(1000, 10000):
        if len(set(eul.get_digits(product))) == len(str(product)):
            for i in eul.get_proper_divisors(product):
                j = int(product / i)
                test = ''.join([str(i), str(j), str(i*j)])
                if len(test) == 9 and eul.pandigital(test):
                    products.add(i*j)
    return sum(products)
Example #2
0
def eul23():
    """Find the sum of all the positive integers which cannot be written as the sum of two abundant numbers."""
    upper = 28123
    abundants = set([x for x in range(12, upper) if sum(eul.get_proper_divisors(x)) > x])
    abundant_sums = set([(i + j) for i in abundants for j in abundants if i+j < upper])
    return sum(set([x for x in range(1, upper)]) - abundant_sums)
Example #3
0
def eul21():
    """Evaluate the sum of all the amicable numbers under 10000."""
    return sum([x for x in range(1, 10000) if
                x != sum(eul.get_proper_divisors(x)) and sum(
                    eul.get_proper_divisors(sum(eul.get_proper_divisors(x)))) == x])