예제 #1
0
파일: Euler71.py 프로젝트: KEClaytor/Euler
def is_reduced_proper_fraction(num, denom):
    common_factors = set(factors(num)) & \
        set(factors(denom))
    if len(common_factors) == 1:
        return True
    else:
        return False
예제 #2
0
파일: Euler21.py 프로젝트: KEClaytor/Euler
def isamicable(n):
    pair = []
    nfac = factors(n)
    nfac.pop()  # Remove the number itself
    dn = sum(nfac)
    dnfac = factors(dn)
    dnfac.pop()
    dnp = sum(dnfac)
    # print n, dn, dnp
    if (dnp == n):
        pair.append(n)
        pair.append(dn)
    return pair
예제 #3
0
파일: Euler23.py 프로젝트: KEClaytor/Euler
def isabundant(num):
    isab = 0
    fac = factors(num)
    fac.pop()  # remove the number itself from the list
    if (sum(fac) > num):
        isab = 1
    return isab
예제 #4
0
파일: Euler12.py 프로젝트: KEClaytor/Euler
from eulermath import factors

if __name__ == "__main__":
    # Test case, 7th triangle number is 28 and is the first to have > 5 factors
    # fmax = 5
    fmax = 500
    i = 1
    # print "i  tri"
    while True:
        # What is the corresponding triangle number
        tri = sum(range(1, i))
        nfac = len(factors(tri))
        # print i, tri, factors(tri)
        if (nfac > fmax):
            break
        i += 1

    print "The first triangle number to have over", fmax, "factors is:", tri