Ejemplo n.º 1
0
        return [2]
    if n == 3:
        return [3]
    for p in primes:
        if p > n:
            break
        S.append(p)
        e = prime_partition(n-p, primes,depth+1)
        if e:
            S.extend(e)
        else:
            S.pop()
        if sum(S) == n and depth == 0:
            S.sort()
            print S
            if S not in N:
                N.append(S)
                count += 1
            S = []
        elif sum(S) == n:
            N.append(S)
            S = []

    if depth == 0:
        return count
    return N


primes = get_primes(100)
print prime_partition(10,primes, 0)
Ejemplo n.º 2
0
            t[i] += 1
            temp /= primes[i]
        if temp == 1:
            return True, t, temp
    return False, t, temp

def analyze(fcount):
    use = [n for n in fcount if n]
    p = 1
    for e in use:
        p *= (e + 1)
    return p

time.clock()
lim = int(math.floor(math.log(2*10**6,3)))
primes = get_primes(50)
p1 = 1
p2 = 1
for e in primes[:lim-1]:
    p1 *= e
    p2 *= e
p2 *= primes[lim-1]*primes[lim]

n = p1
while n < p2:
    a = analyze(factorize(n**2,primes)[1])
    if a > 8*10**6:
        print n, a
        break
    n += p1