示例#1
0
def solve():
    n = 428571
    d = 0
    while True:
        if (7*n+1) % 3 == 0:
            d = (7*n+1) / 3
            print '(n,d) = (%s,%s)' % (n, d)
            break
        n = n - 1
    l1 = mtools.prime_factors(n)
    l2 = mtools.prime_factors(d)
    print l1,l2
    return 'n in hcf(n,d)'
示例#2
0
def min_product_sum_with_start(k, start):
    #print 'min_product_sum_with_start(%d,%d) = ' % (k, start),
    i = start
    while True:
        if not mtools.is_prime(i):
            p, c = mtools.prime_factors(i)
            #i-k + len(factors) == sum(factors)
            if search_match(i, p, c, k):
                #print i
                return i
        i = i + 1
示例#3
0
def prime_prod(n):
   p,c = mtools.prime_factors(n)
   if len(p) == 1 and c[0] > 1:
      return (p[0], c[0])
   return None
示例#4
0
def phi(n):
    p, c = mtools.prime_factors(n)
    s = n
    for x in p:
        s = s - s/x
    return s
示例#5
0
def primes_n(s, n):
    for i in range(s, s+n):
        p, num = mtools.prime_factors(i)
        if len(p) != n:
            return False
    return True