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
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
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
def solve(): for p in allprimes(): while n % p == 0: n //= p if n == 1: return p
def solve(): for n,p in islice(enumerate(allprimes(), start=1), 0, None, 2): if 2 * n * p > 10**10: return n