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
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)
def is_abundant(num): if not num % 2 or not num % 3: return sum(factors(num)) > num
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