Ejemplo n.º 1
0
def solve():
    piter = allprimes()
    next(piter)
    i = 3
    for node in generateAsc([Node(piter)], Node.next):
        if node.val > i:
            return i
        elif node.val == i:
            i += 2
Ejemplo n.º 2
0
def solve():
    piter = allprimes()
    next(piter)
    next(piter)
    p1 = next(piter)
    p2 = next(piter)
    nextMag = 10
    accum = 0
    while p1 <= 1000000:
        while nextMag < p1:
            nextMag *= 10
        accum += p1 + nextMag * ((p2 - p1) * modInverse(nextMag, p2) % p2)
        (p1, p2) = (p2, next(piter))
    return accum
Ejemplo n.º 3
0
def solve():
    for p in allprimes():
        pstr = str(p)
        for d in '012':
            indices = [i for i,c in enumerate(pstr) if c == d]
            if indices:
                for subdex in subsets(indices, nonempty=True):
                    qty = 1
                    for d2 in range(int(d)+1, 10):
                        s2 = pstr
                        for i in subdex:
                            s2 = s2[:i] + str(d2) + s2[i+1:]
                        if isPrime(int(s2)):
                            qty += 1
                            if qty == 8:
                                return p
Ejemplo n.º 4
0
def solve():
    for p in allprimes():
        while n % p == 0:
            n //= p
            if n == 1:
                return p
Ejemplo n.º 5
0
def solve():
    for n,p in islice(enumerate(allprimes(), start=1), 0, None, 2):
        if 2 * n * p > 10**10:
            return n