Пример #1
0
Файл: euler.py Проект: 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))
Пример #2
0
Файл: euler.py Проект: 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()))
Пример #3
0
Файл: euler.py Проект: jdp/euler
 def d(n):
     return sum(sorted(divisors(n))[:-1])