Exemplo n.º 1
0
def Euler47_2(n):
    primes = cpriimes.func(10**(n-1))
    numDiv = 0
    x = 0
    divs = 0
    while numDiv<n:
        divs = 0
        for i in primes:
            if x%i == 0:
                divs += 1
        if divs == n:
            numDiv += 1
        else:
            numDiv = 0
        x += 1
    print x-n
Exemplo n.º 2
0
import pyximport; pyximport.install(reload_support = True)
import cpriimes

primes = cpriimes.func(1000000)
isP = cpriimes.isPrime

def isPrime(i):
    return isP(i, primes)

def isCirclePrime(num):
    for i in xrange(len(str(num))):
        if isPrime(int(str(num)[i:] + str(num)[:i])) == 0:
            return False
    return True
    
print len([i for i in xrange(1000000) if isCirclePrime(i)])
Exemplo n.º 3
0
import pyximport; pyximport.install()
import cpriimes
import itertools as it

itp = it.permutations

allprimes = cpriimes.func(10000)
primes = filter(lambda x: x > 999, cpriimes.func(10000))
primeset = set(primes)

def isPrime(x):
    if cpriimes.isPrime(x, allprimes):
        return True
    return False

def permuts(x):
    nums = list(set([i for i in itp(str(x))]))
    for j in xrange(len(nums)):
        nums[j] = int("".join(nums[j]))
    return sorted(nums)

def seq(x):
    nums = [i for i in permuts(x) if isPrime(i)]
    maxcount = 0
    num = 0
    finalli = 0
    for i in nums:    
        for j in xrange(2, 4500, 2):
            count = 0
            i2 = i
            if i + j in nums:
Exemplo n.º 4
0
import pyximport; pyximport.install()
import cpriimes

primes = cpriimes.func(2000000)

def isPrime(i):
    if cpriimes.isPrime(i, primes):
        return True
    return False

def isTruncPrime(i):
    string = str(i)
    for i in xrange(len(string)):
        if isPrime(int(string[i:])) == 0:
            return False
        elif isPrime(int(string[:i+1])) == 0:
            return False
    return True
    
array = []
i = 10
while len(array)<11:
    if isTruncPrime(i): 
        array.append(i)
    i += 1
print sum(array)