Esempio n. 1
0
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)
Esempio n. 2
0
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
Esempio n. 3
0
def main (limit):
    for n in gen_factorization(limit):
        largestFactor = n

    return largestFactor