Prime Pair Sets

The primes $3$, $7$, $109$, and $673$, are quite remarkable. By taking any two primes and concatenating them in any order the result will always be prime. For example, taking $7$ and $109$, both $7109$ and $1097$ are prime. The sum of these four primes, $792$, represents the lowest sum for a set of four primes with this property.
Find the lowest sum for a set of five primes for which any two primes concatenate to produce another prime.

The algorithm is most probably based on Depth-First Search (DFS) or Breadth-First Search (BFS) where you search through all possible combinations of primes numbers from least to greatest until the fifth combo has every two-prime concatenation result in a new prime.

Here is a Python implementation:

“`python
import itertools, sympy

primes = list(sympy.primerange(1, 10000)) # Adjust the upper limit as needed
solutions = []

def concat_prime(p1, p2):
return sympy.isprime(int(str(p1) + str(p2))), sympy.isprime(int(str(p2) + str(p1)))

for combo in itertools.combinations(primes, 5): # 5 represents the number of primes in a combination
prime_set = list(combo)
is_solution = True

for pair in itertools.combinations(prime_set, 2):
if not all(concat_prime(*pair)):
is_solution = False
break

if is_solution:
solutions.append(sum(prime_set))
break # remove this line to see all solutions

print(“Lowest sum for a set of five primes: “, min(solutions)) if solutions else print(“No solution found”)
“`

This python script will give you the sum of the set of five primes where any two primes concatenate to produce another prime. It’s worth mentioning that the primerange upper limit in the script can be increased to find a solution if it doesn’t exist within 10000. Also, please note that execution time can increase rapidly as you increase the limit.

More Answers:
Square Root Convergents
Spiral Primes
XOR Decryption

Error 403 The request cannot be completed because you have exceeded your quota. : quotaExceeded

Share:

Recent Posts

Mathematics in Cancer Treatment

How Mathematics is Transforming Cancer Treatment Mathematics plays an increasingly vital role in the fight against cancer mesothelioma. From optimizing drug delivery systems to personalizing

Read More »