Exemple #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
Exemple #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
Exemple #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()))
Exemple #4
0
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))
Exemple #6
0
def abundant(number: int) -> bool:
    return sum(proper_divisors(number)) > number
def divisor_sum(n):
    return sum(proper_divisors(n))
Exemple #8
0
def amicable(number: int) -> bool:
    candidate = sum(proper_divisors(number))
    return (sum(proper_divisors(candidate)) == number and candidate != number)
Exemple #9
0
def deficient_number(n):
    return sum(proper_divisors(n)) < n
Exemple #10
0
def perfect_number(n):
    return sum(proper_divisors(n)) == n
Exemple #11
0
def abundant_number(n):
    return sum(proper_divisors(n)) > n
Exemple #12
0
def abundant(n):
    return sum(utils.proper_divisors(n)) > n
Exemple #13
0
def is_abundant(n):
    condition = sum(utils.proper_divisors(n)) > n
    return True if condition else False
Exemple #14
0
def divisor_sum(n):
    return sum(proper_divisors(n))