Example #1
0
def get_n(p1, p2):
    d = mtools.count_digits(p1)
    dd = 10**d
    _, b0 = euclidean(dd, p2)
    t = int(math.floor(p1*b0/dd))
    b = p1*b0 - dd*t
    assert b > 0
    n = b*p2
    return n
Example #2
0
def count_partition(n):
    stack = [(1, n, [])]
    cnt = 0
    ls = []
    while stack:
        p, r, l = stack.pop()
        j = mtools.count_digits(p)
        k = mtools.count_digits(r)
        for (m,r1) in trunc_number(r, j, k/2):
            l2 = l[:]
            if m > p and is_prime(m):
                l2.append(m)
                stack.append((m, r1, l2))
                if r1 > m and is_prime(r1):
                    l3 = l2[:]
                    l3.append(r1)
                    cnt += 1
                    ls.append(l3)
    return cnt, ls