def max_prime_list(pair): a, b = pair prime_seq_len = 0 n = 0 while n < b: q = n**2 + a*n + b if q > 1 and is_prime(q): prime_seq_len += 1 n += 1 else: break return prime_seq_len
def extend_right(right): candidates = [int(str(n) + str(p)) for p in right for n in range(1,10)] return [p for p in candidates if is_prime(p)]
def extend_left(left): candidates = [a*10 + b for a in left for b in [1, 3, 7, 9]] return [p for p in candidates if is_prime(p)]
def extend(left, right): candidates = [a*10 + b%10 for a in left for b in right if str(a)[1:] == str(b)[:-1]] return [p for p in candidates if is_prime(p)]
#By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, #we can see that the 6th prime is 13. #What is the 10001st prime number? from eulermath import is_prime import time number_prime_to_find = 10001 prime_count = 1 i = 3 t0 = time.time() while True: if is_prime(i): prime_count += 1 if prime_count == number_prime_to_find: break i += 2 t1 = time.time() print "The " + str(number_prime_to_find) + "th prime is", i print t1 - t0