示例#1
0
def all_divides(max_val):
    factor = factor_big_nums(max_val)
    all_factors = Counter()
    for j in xrange(2, max_val + 1):
        num_factors = Counter(factor(j))
        for num_factor, count in num_factors.iteritems():
            all_factors[num_factor] = max(all_factors[num_factor], count)
    smallest = 1
    for key, value in all_factors.iteritems():
        smallest *= (key ** value)
    return smallest
示例#2
0
def factor_repunit(num_digs):
    factor = factor_big_nums(10 ** num_digs)
    return factor(repunit(num_digs) / 11)
示例#3
0
def factor(num):
    return factor_big_nums(num)(num)
def test_factor_big_nums():
    big_num = reduce(lambda j, k: j * k, small_primes)
    factor = factor_big_nums(big_num)
    factors = sorted(list(factor(big_num)))
    assert_list_equal(factors, list(small_primes))