Here is a video on Truncatable Primes. I tried to build it myself. Here is what I have tried using the method in the video for left Truncatable Primes
.
myNextList[n_] := Select[10^(Length[IntegerDigits[n]])*Range[9] + n, PrimeQ];
SetAttributes[myNextList, Listable];
So a bit of testing:
myNextList[91]
{191, 491, 691, 991}
myNextList[3947]
{}
and
myNextList[{13, 23, 43, 53, 73, 83}]
{{113, 313, 613}, {223, 523, 823}, {443, 643, 743}, {353, 653, 853, 953}, {173, 373, 673, 773}, {283, 383, 683, 883, 983}}
Now the goal is to repeate the proccess until we get none of them returns a prime. So I tried
NestWhileList[myNextList, 7, AllTrue[#, PrimeQ] &]
NestWhile[myNextList, 7, AllTrue[#, PrimeQ] &]
{{317, 617}, {137, 337, 937}, {347, 547, 647, 947}, {167, 367, 467, 967}, {197, 397, 797, 997}}
which should be continued ...
myNextList[%]
{{{6317, 8317}, {2617, 3617}}, {{2137, 3137, 9137}, {4337, 6337, 9337}, {4937, 7937}}, {{2347, 3347, 5347}, {3547, 4547, 6547, 7547, 9547}, ...
I think it's an easy fix, with the test
part, which I have used AllTrue[#, PrimeQ] &
. But I don't know how to fix it.
If I just use
Nest[myNextList, 1, 8]
Nest[myNextList, 7, 8]
Nest[myNextList, 7, 16]
for example, it all worked fine. But I want to repeat something from the video and find all 1422 end points (as stated in the video at 04:49)