Example #1
0
def E4A():
    '''Return the largest palindrome P, where p = A * B, and A, B > 100'''
    ps = gen_palindromeList()
    for n in ps:
        pCount = Counter()
        for p in gen_PrimeFactors(n):
            pCount.update(p)
        A, B = greatestPair(pCount)
        if intlen(A) == 3 and intlen(B) == 3:
            return n
Example #2
0
def E5A(n):
    '''Determing the smallest number that is evenly divided by all numbers <= n'''
    def maxMerge(a, b):
        for k, v in b.iteritems():
            if a[k] < v:
                a[k] = v

    master = Counter()
    x = range(2, n + 1)
    for i in x:
        tmp = Counter()
        for p in gen_PrimeFactors(i):
            tmp.update(p)
        maxMerge(master, tmp)

    s = 1
    for k, v in master.iteritems():
        s *= k**v

    return s