def get_primes(): primes = [] for i in range(1, 1000000): if i % 100000 == 0: print("At i = %s" % i) if is_prime(i): primes.append(i) print("primes", primes) return primes
primes = [] highest = [0.0] def find_consecs(n, p, h): for i in range(0, len(p)): c, j = 0, 0 while c < n: c += p[i + j] j += 1 if c == n: if j > h[0]: h = [j, n] if c > n: break return h for i in range(1, limit): if i % 10000 == 0: print("i = %s" % i) if is_prime(i): primes.append(i) else: continue highest = find_consecs(i, primes, highest) print("[Highest seq, Highest num] = %s" % highest) # Answer: 997651
import sys from Scripts import is_prime maximum = 1000000000 counter = 0 for number in range(2, 1000000000): if number is 2 or number % 2 != 0: if is_prime(number): counter += 1 if counter % 1000 == 0: print("Primes Found: " + str(counter)) if counter == 10001: print("10 001th prime found! ---> %s" % number) sys.exit(number) print("Incomplete. Primes Found: %s" % counter) # Answer: 104743
from Scripts import is_prime def is_pandigital(n): n = str(n) for i in range(1, len(n) + 1): if str(i) not in n: return False return True highest = 0 limit = 999999999 for i in reversed(range(1, limit, 2)): if i % 10000001 == 0: print("At %s" % i) if is_pandigital(i): if is_prime(i): print("%s is largest pandigital prime" % i) break # Answer: 7652413
from Scripts import is_prime for t in range(0, 10000): if t % 1000 == 0: print("t = %s" % t) arr = [] for i in range(0, 10000): # print("i = %s" % i) if i + 2 * t > 10000: # print("broke, limit") break if not is_prime(i): # print("broke, prime") continue arr = [i] for j in range(1, 3): i += t arr.append(i) valid = True dict = {} # print(arr) for a in str(arr[0]): dict[a] = str(arr[0]).count(a) # print(dict) for a in arr: if not is_prime(a): valid = False for b in str(a): if b not in dict: valid = False continue