Example #1
0
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
Example #2
0
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
Example #3
0
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()))
Example #4
0
def sum_of_proper_divisors(n):
    divs = proper_divisors(n)
    if divs:
        return sum(divs)
    else:
        return 1
Example #5
0
def d(n):
    """sum of proper divisors of n."""
    return sum(proper_divisors(n))
Example #6
0
def abundant(number: int) -> bool:
    return sum(proper_divisors(number)) > number
Example #7
0
def divisor_sum(n):
    return sum(proper_divisors(n))
Example #8
0
def amicable(number: int) -> bool:
    candidate = sum(proper_divisors(number))
    return (sum(proper_divisors(candidate)) == number and candidate != number)
Example #9
0
def deficient_number(n):
    return sum(proper_divisors(n)) < n
Example #10
0
def perfect_number(n):
    return sum(proper_divisors(n)) == n
Example #11
0
def abundant_number(n):
    return sum(proper_divisors(n)) > n
Example #12
0
def abundant(n):
    return sum(utils.proper_divisors(n)) > n
Example #13
0
def is_abundant(n):
    condition = sum(utils.proper_divisors(n)) > n
    return True if condition else False
Example #14
0
def divisor_sum(n):
    return sum(proper_divisors(n))