Esempio n. 1
0
File: euler.py Progetto: jdp/euler
def euler_23():
    """Find the sum of all the positive integers which cannot be written as the sum of two abundant numbers."""
    from eutil import divisors

    abundants = set([n for n in range(1, 20162) if sum(sorted(divisors(n))[:-1]) > n])
    return sum(n for n in range(1, 20162) if not any(((n - a) in abundants) for a in abundants))
Esempio n. 2
0
File: euler.py Progetto: jdp/euler
def euler_12():
    """What is the value of the first triangle number to have over five hundred divisors?"""
    from itertools import dropwhile
    from eutil import triangle_numbers, divisors

    return next(dropwhile(lambda x: len(divisors(x)) < 500, triangle_numbers()))
Esempio n. 3
0
File: euler.py Progetto: jdp/euler
 def d(n):
     return sum(sorted(divisors(n))[:-1])