## Thursday, March 05, 2020

### Primes describing digit position

On Monday, Éric Angelini posted this to the Sequence Fanatics Discussion list: S = 11, 41, 61, 83, 113, 101, ... with digits 1, 1, 4, 1, 6, 1, 8, 3, 1, 1, 3, 1, 0, 1, ... at positions 1, 2, 3, 4, ...

11 says: "In position 1 is a 1."
41 says: "In position 4 is a 1."
61 says: "In position 6 is a 1."
83 says: "In position 8 is a 3."
113 says: "In position 11 is a 3."
101 says: "In position 10 is a 1."
etc.

Of course, each added prime must be the smallest possible that has not already been used. There's a few early surprises hinting at things to come: 11, 41, 61, 83, 113, 101, 151, 181, 233, 223, 263, 293, 353, 383, 419, 401, 479, 467, 541, 1009, 599, 631, 661, 691, 727, 751, 787, 797, 809, 877, 907, 919, 967, 991, 9001, 1031, ... Term #20 is 1009 because to the end of term #19 we have 53 digits/positions and term #19 says that the next digit (position 54) is a 1. So we need a prime starting with 1 and 1009 is the smallest one that keeps the growing sequence truthful. Term #20 also dictates that in position 100 is a 9. So when we get to term #34 = 991, we now have 99 digits/positions and so the next prime must start with a 9. Why not 997? Because that says that in position 99 is a 7 and we already know that in position 99 is a 1. So we must travel all the way up to 9001 to keep things honest. And that may have repercussions when we get to position 900.

I eventually wrote a Mathematica program that seemed to work extending the sequence. But it was taking a long time finding term #1447. So I had a look at how far it had gotten. Term #1446 was 190901 taking up positions 7006-7011. Perusing the list of prior terms, I saw that positions 7012-7020 and 7022-7024 were already assigned with digits: 191737191?371... Stepping through, 19 is prime, as is 191, but these lie: position 1 is not 9; position 19 is not 1. Continuing, no more primes up to 191737191. Then we can try 1917371911, 1917371913, 1917371917, 1917371919, replacing the ? with 1, 3, 7, 9, but these are not prime either. So we attach the next digit, 3, and replace the ? with 0, 1, 2, 3, ..., 9. We need not go further than 5 because 19173719153, finally, is prime!

So I managed to figure out term #1447 before my program did! In fact, it would not have found it because I had my initial search go up to only 104395301. Here's a graph (click on it) of 1500 terms:

Sunday, March 8: I have run into a second large term at #3868. Term #3867 was 301471 taking up positions 21005-21010. Positions 21011-21020 and 21022-21028 were already assigned with digits: 3713793719?9317373... So #3868 is 371379371929 and #3869 is 31737313.

Monday, March 9: This is now OEIS A333085. It needs a decent Mathematica program!

Wednesday, March 11: I have rewritten my original program to run significantly faster. In fact, the new version has already overtaken the number of terms calculated by the old one. Here's an updated graph.

Monday, March 16: I've reached 12000 terms and primes strictly greater than 700000.

Thursday, March 19: Maximilian Hasler has written PARI/GP code for this sequence which he says computes 10000 terms in a few seconds. Unfortunately, I haven't been able to get it to run.

Tuesday, March 31: I've decided to call it quits at 18000 terms. There was another spike at #16966.