for x in range(2, 10 ** 6): if x >= digCountEdge: digCount += 1 digCountEdge = pow10[digCount] p = pow10[digCount - 1] if x != 2: skip = True y = x del c[0:len(c)] while True: y, d = divmod(y, 10) if d % 2 == 0: break y += d * p if y < x: break elif y == x: skip = False break c.append(y) if skip: continue if isPrime(x) and all(isPrime(x) for x in c): c.insert(0, x) print(c) result += len(c) print(result)
for x in range(2, 10**6): if x >= digCountEdge: digCount += 1 digCountEdge = pow10[digCount] p = pow10[digCount - 1] if x != 2: skip = True y = x del c[0:len(c)] while True: y, d = divmod(y, 10) if d % 2 == 0: break y += d * p if y < x: break elif y == x: skip = False break c.append(y) if skip: continue if isPrime(x) and all(isPrime(x) for x in c): c.insert(0, x) print(c) result += len(c) print(result)
heads = queue.Queue() for h in [2, 3, 5, 7]: heads.put(h) result = 0 resultCount = 0 p10 = 1 while resultCount < 11: h = heads.get() * 10 while h > p10: p10 *= 10 p10 //= 10 for t in range(1, 10, 2): x = h + t if not nums.isPrime(x): continue heads.put(x) p = p10 y = x good = True while p > 1: y %= p if not nums.isPrime(y): good = False break p //= 10 if good: result += x resultCount += 1