from tools import number_theory def search(limit): prime = [1] + list(number_theory.make_prime(1000000)) for n in range(1, len(prime), 2): p = prime[n] r = 2 * n * p % (p ** 2) if r > limit: return n print(search(10 ** 10))