コード例 #1
0
ファイル: sol.py プロジェクト: KholdStare/projecteuler
def count_divisors(n, primeList):
    """Get prime factorization, and count all possible combination of those
    prime factors"""
    countDict = count_occurances(gen_factorization(n, primeList))

    # just the counts of the prime factors, not the facors themselves
    # we dont care about them anymore
    countList = countDict.values()

    return reduce(operator.mul, (d+1 for d in countList) , 1)
コード例 #2
0
ファイル: sol.py プロジェクト: KholdStare/projecteuler
def main(number):
    nums_to_consider = range(2, number+1)
    # How many times a prime is used to compose a given number in the list
    primeUsage = {}

    for num in nums_to_consider:
        primeUsage[num] = 0
        countDict = count_occurances(gen_factorization(num))
        for dPrime in countDict.iterkeys():
            primeUsage[dPrime] = max(countDict[dPrime], primeUsage[dPrime])

    result = 1
    for key in primeUsage:
        if primeUsage[key]:
            result *= (key ** primeUsage[key])

    return result
コード例 #3
0
ファイル: sol.py プロジェクト: KholdStare/projecteuler
def main (limit):
    for n in gen_factorization(limit):
        largestFactor = n

    return largestFactor