(Python 2.7) def check_prime(number): if number == 2: return True if number % 2 == 0: return False i = 3 while number % i != 0: i += 2 if i*i > number: return True return False def list_n_primes(n): if n < 3: return [2] if n == 2 else [] primes = [2, 3] i = 0 while len(primes) < n: i += 6 if check_prime(i - 1): primes.append(i - 1) if check_prime(i + 1) and len(primes) < n: primes.append(i + 1) return primes def check_divisors(num0, num1, primes = None): maxnum = max(num0, num1) minnum = min(num0, num1) if primes is None: primes = list_n_primes(maxnum) i = 0 sum = 0 while primes[i]*primes[i] <= maxnum: if maxnum % primes[i] == 0 and minnum % primes[i] == 0: sum += 1 i += 1 return sum def create_list(): primes = list_n_primes(10000) bar = 0 p = Prime_finder() current = p.next_prime() last = current prime_factorial = 1 power = 1 while True: last = current current = p.next_prime() if current > primes[-1]: primes.append(current) divs = -1 if current - last >= prime_factorial: divs = check_divisors(last + 1, current + 1, primes) if divs >= bar: print(divs, last, current) prime_factorial *= primes[bar] bar += 1 if last > power: power *= 10 print(power) class Prime_finder: def __init__(self): self.prime_iteration = 0 def next_prime(self): self.prime_iteration += 1 if self.prime_iteration == 1: return 2 if self.prime_iteration == 2: return 3 while not check_prime(int(self.prime_iteration / 2) * 6 + (self.prime_iteration % 2 * 2 - 1)): self.prime_iteration += 1 return int(self.prime_iteration / 2) * 6 + (self.prime_iteration % 2 * 2 - 1) create_list()