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.
(In other words: the smallest prime of the family contains one digit, or a larger number of identical digits, which, when replaced with another digit or other identical digits, fills out the family to eight members.) Project Euler problem 51
Consider 56003 with the digits being replaced as 56xx3 as in the example.
The mod 3 value of the non-changing digits, 563, (or of the sum of digits of 563) is 2.
If 2 more identical digits are added, either 0, 1, or 2 will be added to the mod 3 value of the entire 5-digit number.
In other words, only 2/3 of the 10 possible family members have the possibility of being prime, e.g. 7 as in the example.
Whatever the sum of digits of the non-replaced digits, if the number of replaced digits is 1 or 2 mod 3, then the maximum size of a family will be 7. In this case, 56223, 56553, and 56883 are all divisible by 3.
The only way to get more than 7 is for the non-replaced digits to have a mod 3 value of 1 or 2, and then for the number of replaced digits to be a multiple of 3 so that the replaced digits contribute zero to the mod 3 value of the number.
Also, the last digit cannot be one of the digits which varies since the family size could be at most 4 (primes only end in 1,3,7,9).
Next suppose you have an n-digit number and you want to replace n-1 digits. The last digit must be fixed, must be odd and divisible by 3 so the last digit can only be 3 or 9. Furthermore, this means you're replacing the first digit, which you cannot replace with 0, so you only have 9 chances to find 8 primes.
The only patterns to search are those in which we replace 3 (or 6, 9, 12, etc) digits.
|
Posted by Larry
on 2024-02-16 17:38:52 |