By replacing the 1st digit of *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.
analyse:
1) If we replace the last digit with 0-9 we get: xxxx0, xxxx1, xxxx2, ..., xxxx9.
This yield at least to four even numbers, xxxx2,xxxx4,xxxx6,xxxx8, which of cause aren't prime.
So the last digit can't be replaced.
2) Digit must be less or equal than 2 to generate a family of eight. 0-7, 1-8, 2-9.
performance improvements: 30 ms -> 17 ms.
add 1) Don't check last digit for equalness.
add 2) Only check digits less or equal 2.
Problem51 = 121313 elapsed time: 17 ms. Test Passed.
Geen opmerkingen:
Een reactie posten