예제 #1
0
def main():
    result = 0
    test_numbers = list(range(1, 10000))
    for i in test_numbers:
        a = sum(list(factors(i))[:-1])
        b = sum(list(factors(a))[:-1])
        if i == b and a != b:
            test_numbers.remove(max(a, b))
            result += a + b
    return result
예제 #2
0
파일: 12-2.py 프로젝트: sejje/sejje-euler
def first_triangle_with_divisors(num):
    '''
    Find the first triangle number with
    at least num number of divisors
    '''
    count = 1
    triangle = 1
    factor_count = 0
    while factor_count < num:
        count += 1
        triangle += count
        if num < 100 or num > 100 and not triangle % 2 and not triangle % 3:
            factor_count = len(factors(triangle))
    return (triangle, factor_count)
예제 #3
0
파일: 12-2.py 프로젝트: sejje/sejje-euler
def first_triangle_with_divisors(num):
    '''
    Find the first triangle number with
    at least num number of divisors
    '''
    count = 1
    triangle = 1
    factor_count = 0
    while factor_count < num:
        count += 1
        triangle += count
        if num < 100 or num > 100 and not triangle % 2 and not triangle % 3:
            factor_count = len(factors(triangle))
    return (triangle, factor_count)
예제 #4
0
def is_abundant(num):
    if not num % 2 or not num % 3:
        return sum(factors(num)) > num
예제 #5
0
def abundant_numbers(n=1000):
    # find all abundant numbers up to n
    for i in range(12, n):
        a = sum(list(factors(i))[:-1])
        if a > i:
            yield i
예제 #6
0
파일: 23.py 프로젝트: sejje/sejje-euler
def is_abundant(num):
	if not num % 2 or not num % 3:
		return sum(factors(num)) > num