def main(limit): primes = Primes(limit) def circular(p): d = digits(p) return all(primes.isPrime(num(d[i:] + d[:i])) for i in range(1, len(d))) return sum(map(circular, takewhile(lambda n: n < limit, primes.gen())))
def main(limit): primes = Primes(limit) def circular(p): d = digits(p) return all( primes.isPrime(num(d[i:] + d[:i])) for i in range(1, len(d))) return sum(map(circular, takewhile(lambda n: n < limit, primes.gen())))
break yield a nw.append(a) if not nw: return ws = nw def dpf(n): return set(p for p, _ in primes.factors(n)) primes = Primes() def main(limit): hits = set() for c in range(limit): f = list(primes.factors(c)) R = multiply(p**(n-1) for p, n in f) badf = set(p for p, _ in f) for a in aa((p for p in primes.gen() if p not in badf), c): b = c - a if a < b and rad(a)*rad(b) < R and dpf(b).isdisjoint(dpf(a) | badf): hits.add((a, b, c)) return sum(c for _, _, c in hits) if __name__ == '__main__': print(main(1000)) # 18407904 c = 9 for a in aa((p for p in primes.gen() if p not in dpf(c)), c): print(a)
ws = nw def dpf(n): return set(p for p, _ in primes.factors(n)) primes = Primes() def main(limit): hits = set() for c in range(limit): f = list(primes.factors(c)) R = multiply(p**(n - 1) for p, n in f) badf = set(p for p, _ in f) for a in aa((p for p in primes.gen() if p not in badf), c): b = c - a if a < b and rad(a) * rad(b) < R and dpf(b).isdisjoint( dpf(a) | badf): hits.add((a, b, c)) return sum(c for _, _, c in hits) if __name__ == '__main__': print(main(1000)) # 18407904 c = 9 for a in aa((p for p in primes.gen() if p not in dpf(c)), c): print(a)