def truncatable_primes():
    sieve = PrimeSieve(1000000)
    res = []
    for prime in sieve.primes()[4:]:  # The 5th prime is 11, the first prime greater than 10
        if _is_truncatable_from_both_directions(prime, sieve):
            res += [prime]
        if len(res) >= 11:  # According to problem description there are exactly 11 truncatable primes
            break
    return res
def circular_primes(upper_limit):
    sieve = PrimeSieve(upper_limit + 1)
    return [x for x in sieve.primes() if _is_circular_prime(x, sieve)]
 def test_sum_of_primes_less_than_two_million(self):
     prime_sieve = PrimeSieve(2000000)
     self.assertEqual(sum(prime_sieve.primes()), 142913828922)
 def test_10001_th_prime_number_is_104743(self):
     prime_sieve = PrimeSieve(500000)
     self.assertEqual(prime_sieve.primes()[10000], 104743)