Exemplo n.º 1
0
Arquivo: euler.py Projeto: 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))
Exemplo n.º 2
0
Arquivo: euler.py Projeto: 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()))
Exemplo n.º 3
0
Arquivo: euler.py Projeto: jdp/euler
 def d(n):
     return sum(sorted(divisors(n))[:-1])