Each Prime can (mostly) be generated by having an existing Prime, then padding it either in front or back by a single digit (and the resulting number will be a Prime as well).
example:
23 is a Prime, Add a 2 in front: 223 is also a Prime 11 is a Prime, Add a 3 in the back: 113 is also a Prime Now there are some Primes that this pattern does not exist for. I am trying to see which ones do not fit this category.
So If I start by getting a few Primes, then pad them and see if results are Prime:
Front-padding:
FromDigits@*Flatten@*IntegerDigits /@ Select[Tuples[{Range[9], Prime[Range[10]]}], PrimeQ[FromDigits[ Join[IntegerDigits[#[[1]]], IntegerDigits[#[[2]]]]]] &] ===>
{13, 17, 113, 23, 211, 223, 229, 37, 311, 313, 317, 43, 47, 419, 53, 523, 67, 613, 617, 619, 73, 719, 83, 811, 823, 829, 97, 911, 919, 929} Back-padding:
FromDigits@*Flatten@*IntegerDigits /@ Select[Tuples[{Prime[Range[10]], Range[10] - 1}], PrimeQ[FromDigits[ Join[IntegerDigits[#[[1]]], IntegerDigits[#[[2]]]]]] &] ===>
{23, 29, 31, 37, 53, 59, 71, 73, 79, 113, 131, 137, 139, 173, 179, 191, 193, 197, 199, 233, 239, 293} Those are also all Primes - however this is just giving me a list. I need to:
1-Merge them into a single list, ordered.
2-More importantly, see which original primes did not have a resulting Prime. Those need to be identified. (Ex: 773) - If we expand the original Range of 10
Union[](for merging and sorting lists)? $\endgroup$