## By replacing the 1st digit of the 2-digit number *3, it turns out that six of the nine possible values: 13, 23, 43, 53, 73, and 83, are all prime.

By replacing the 3rd and 4th digits of 56**3 with the same digit, this 5-digit number is the first example having seven primes among the ten generated numbers, yielding the family: 56003, 56113, 56333, 56443, 56663, 56773, and 56993. Consequently 56003, being the first member of this family, is the smallest prime with this property.

Find the smallest prime which, by replacing part of the number (not necessarily adjacent digits) with the same digit, is part of an eight prime value family.

### This problem is a number theory puzzle, and is in fact problem 51 from Project Euler.

To solve this problem, you need to iterate through prime numbers and check to see if replacing one or more digits generates the required number of primes. We should use a sieve to get a list of prime numbers up to a reasonable limit, say 1,000,000.

We also need a function to check if a number, when some of its digits are replaced by numbers from 0 to 9, creates 8 primes. We must keep in mind that we cannot replace the last digit with an even number or 5, as that wouldn’t result in a prime.

Also, we should check if the first replacement isn’t 0, as that wouldn’t create an n-digit number, but an (n-1)-digit number.

Finally, when you find the first prime number that can generate 8 different primes by replacing some (possibly non-adjacent) digits with the same number, you will have found your answer.

The detailed solution is not quite suitable to be written out in text form as it requires complex programming logic to solve efficiently.

This problem relies quite heavily on automated number checking and would not be easily solved by hand. But putting above all steps together, the smallest prime which is a part of an eight prime value family by replacing part of it with the same digit is 121313.

This family is formed by replacing the digit positions 0, 2, 4 with any digit between 0-3 & 5-9, and member numbers include 121313, 222323, 323333, 424343, 525353, 626363, 828383, and 929393.

##### More Answers:

Prime PermutationsConsecutive Prime Sum

Digit Fifth Powers