def factors(num, primes = None): factors = [] if num > 3: buf = num if primes: fcandidates = [prime for prime in primes if prime < (num/2) +1] else: fcandidates = prime_sieve((num/2)+1) for candidate in fcandidates: cond = True while cond: r = buf % candidate if r == 0: factors.append(candidate) buf /= candidate elif buf == 1: break else: cond = False return factors
def main(): primes = prime_sieve(1000) minns = [] for k in range(2, 200): cond = True n = 2 while cond: if n in primes: n += 1 continue combs = reductions_full(n) for item in combs: # pad with ones s = sum(item) + k - len(item) pr = prod(item) # print n, pr, s if s == pr: print("K: %d, N: %d, pr: %d, s: %d" % (k, n, pr, s)) if pr not in minns: minns.append(pr) cond = False break n += 1 print sum(minns)