def amicable_pair(a): b = sum(proper_divisors(a)) c = sum(proper_divisors(b)) if a == c and a != b: print "amicable pair found: {}, {}".format(a, b) return a, b else: return None, None
def single_pythagorean(L): factors = sorted(utils.proper_divisors(L / 2)) triplets = [] for m in factors: if m > math.sqrt(L / 4): n = L // (2 * m) - m print(m, n) if n > 0: triplet = pythagorean_triplet(m, n) triplets.append(triplet) print(triplets) if len(set(triplets)) > 1: return False if len(set(triplets)) == 0: return False else: return True
import utils d = {} utils.initialize_primes_cache(10001) for i in range(1, 10000): d[i] = sum(utils.proper_divisors(i)) def amicable_pairs(): for i in range(1, 10000): for j in range(i + 1, 10000): if d[i] == j and d[j] == i: yield i + j print(sum(amicable_pairs()))
def sum_of_proper_divisors(n): divs = proper_divisors(n) if divs: return sum(divs) else: return 1
def d(n): """sum of proper divisors of n.""" return sum(proper_divisors(n))
def abundant(number: int) -> bool: return sum(proper_divisors(number)) > number
def divisor_sum(n): return sum(proper_divisors(n))
def amicable(number: int) -> bool: candidate = sum(proper_divisors(number)) return (sum(proper_divisors(candidate)) == number and candidate != number)
def deficient_number(n): return sum(proper_divisors(n)) < n
def perfect_number(n): return sum(proper_divisors(n)) == n
def abundant_number(n): return sum(proper_divisors(n)) > n
def abundant(n): return sum(utils.proper_divisors(n)) > n
def is_abundant(n): condition = sum(utils.proper_divisors(n)) > n return True if condition else False