def main(): primes = get_all_primes_until(10000)[168:] for step in range(1111,5000): for prime in primes: if is_prime(prime + step) and is_prime(prime + 2 * step): if is_permutation(prime, prime + step) and is_permutation(prime, prime + 2 * step): print(prime, prime + step, prime + step * 2)
def is_circular_prime(n): if is_prime(n): flag = True for i in range(1, len(str(n))): if not is_prime(int(str(n)[-i:] + str(n)[:-i])): flag = False return flag else: return False
def is_truncatable_prime(n): flag_right = False flag_left = False for i in range(len(str(n)) - 1, 0, -1): if is_prime(n % (10 ** i)): flag_left = True else: return False for j in range(1, len(str(n))): if is_prime(int(n / 10 ** j)): flag_right = True else: return False if flag_right and flag_left: return True return False
def main(): ans = 0 max_con = 21 primes = get_all_primes_until(10000) for i in range(len(primes)): for j in range(i + 1): q = sum(primes[j:len(primes) - 1 - i + j]) if is_prime(q) and q < 1000000: if len(primes) - i > max_con: max_con = len(primes) - i ans = q print(ans, max_con)
def main(): primes = 0 number = 10 ans = 0 while primes < 11: if is_prime(number): if is_truncatable_prime(number): print(number) primes += 1 ans += number number += 1 print(ans)
def main(): ans = 0 numbers = list(itertools.permutations( ['1', '2', '3', '4', '5', '6', '7'])) # there is no pandigital prime with 8/9 digits O_o for i in reversed(numbers): number = '' for digit in i: number += digit if is_prime(int(number)): ans = int(number) break print(ans)
def main(): current = 9 prime_counter = 3 counter = 5 h = 3 while (prime_counter * 100) / counter >= 10: h += 2 for i in range(4): current += h - 1 if is_prime(current): prime_counter += 1 counter += 1 print(h)
def main(): for i in range (9, 100000000000000 , 2): if not goldbach(i) and not is_prime(i): print(i) break
def get_all_primes_until(n): primes = [1, 2] for i in range(3, n, 2): if is_prime(i): primes.append(i) return primes