This is the second problem in a new contest in the Brainsteem family. I have noticed a lot of solutions to past problems are given using computational methods. So, just for you, a new series specifically designed to be solved computationally. You may also give analytical solutions as the early ones will be fairly simple.
The Background
Imagine a prime number written in base 10 such that p = d1d2d3d4...dn where each d is a digit and n is the number of digits.
Now think of the sequence of primes such that,
p1 = d1
p2 = d1d2
p3 = d1d2d3
. . .
pn = d1d2d3d4...dn
For example,
p1 = 3
p2 = 31
p3 = 313
p4 = 3137
p5 = 31379
p6 = no primes
So in this case, the maximum prime is p5 with length n=5.
Notice that in this sequence we are adding digits to the right of each prime. It is also possible to add digits to the left, so that we have p = dndn-1...d3d2d1 and, for example, the sequence 3, 13, 313, 3313, and so on.
The Question
Two questions this time.
A. Find the largest possible prime number that can be generated by starting with a single-digit prime and adding digits to the RIGHT of each prime. Let's call this p(max, right).
B. Find the largest possible prime number that can be generated by starting with a single-digit prime and adding digits to the LEFT of each prime. Let's call this p(max, left).
For the First Prize, please include a valid method, algorithm or post the code and output.
If two different people get each of A and B correct, I shall split the First Prize. All others can participate so long as you have done or attempted either A or B.
Remember that even if you are not the first to post, this remains a learning experience that can help in future Brainsteem challenges.
Prizes
To qualify you must upvote this post and write the answer in a comment.
To win First Prize you must include the answer and a valid method.
The First Prize will be 40% of the earnings generated by this post, paid in SBD.
The Second Prize will be 10% of the earnings generated by this post, awarded to any other correct answer in the comments section, chosen at random and paid in SBD.
Also remember that your upvote generates curation rewards for you and that 25% of all earnings are given to upvoters.
Prizes will be awarded after the 7 days have expired. Winners will be announced in the comments below after the draw.
The Prizes will increase with more participation and as the earnings increase.
The main thing is to enjoy the challenge and maybe learn something new.
Come and check out other challenges currently live!
Brainsteem Quickfire Q4 [Win 40% and 10% in SBD]
Brainsteem Compute #1 Prize Computational Maths Puzzle [Win 40% and 10% in SBD]
Brainsteem #8 Prize Maths Puzzle [Win 2SBD+1SBD]
Science Cryptic Crossword SCX1 [Win 10 SBD Prize]
Brainsteem #7 Prize Maths Puzzle [Win 2SBD+1SBD]
Please upvote, resteem and follow @rycharde for more Brainsteems!
I am experimenting with tags, so the easiest way to see all Brainsteems is to follow me. Thanks.
And don't forget to upvote each other's comments to bring cheer to the whole community!