Thursday, 2 November 2023

The Everyone Prime

The title of this post is a play on words and references a type of prime that has a home in OEIS A069246:


 A069246

Primes which yield a prime whenever a 1 is inserted anywhere in them (including at the beginning or end).



I came across such a prime as usual via the number associated with my diurnal age today: 27241. The insertion of a 1 in every possible position yields the numbers 127241, 217241, 271241, 272141 and 272411, all of which are prime. The initial members of the sequence are:

3, 7, 13, 31, 103, 109, 151, 181, 193, 367, 571, 601, 613, 811, 1117, 1831, 4519, 6871, 11119, 11317, 11467, 13171, 16141, 17167, 18211, 18457, 27241, 38917, 55381, 71317, 81199, 81931, 86743, 114031, 139861, 141667, 151687, 179203, 200191

The previous prime, 18457, marked my diurnal age long before I started tracking it and the next such prime, 38917, will occur long after I'm gone.

Insertions of the digits 3 and 7 are also possible and this yields two further OEIS sequences, namely OEIS A215419 and OEIS A215420 respectively.


 A215419

Primes that remain prime when a single digit 3 is inserted between any two consecutive digits or as the leading or trailing digit.



The initial members are:

7, 11, 17, 31, 37, 73, 271, 331, 359, 373, 673, 733, 1033, 2297, 3119, 3461, 3923, 5323, 5381, 5419, 6073, 6353, 9103, 9887, 18289, 23549, 25349, 31333, 32933, 33349, 35747, 37339, 37361, 37489, 47533, 84299, 92333, 93241, 95093, 98491, 133733, 136333, 139333, 232381, 233609


 A215420

Primes that remain prime when a single digit 7 is inserted between any two consecutive digits or as the leading or trailing digit.



The initial members are:

3, 19, 97, 433, 487, 541, 691, 757, 853, 1471, 2617, 2953, 4507, 6481, 7351, 7417, 8317, 13177, 31957, 42457, 46477, 47977, 50077, 59053, 71917, 73897, 74377, 77479, 77743, 77761, 79039, 99103, 175687, 220897

In creating the SageMath code to generate these sequences, I was initially perplexed as to how to proceed but a quick review of how to insert characters into an existing string soon clarified matters. The code is quite succinct and flexible thanks to the insert variable. An insert character of "1" is shown below but inserts of "3" and "7" yield the other two sequences (permalink).

L=[]
insert="1"
for p in prime_range(250000):
    number=str(p)
    OK=1
    for i in [0..len(number)]:
        if is_prime(int(number[:i]+insert+number[i:]))==0:
            OK=0
            break
    if OK==1:
        L.append(p)
print(L)

The code also makes it easy to investigate inserts of "11", "33, "77", "13", "17" and so on although the resulting sequences of numbers don't show up in the OEIS. The code can also be modified so that the insertions occur within the number itself and not before and after. In the case of "1" this yields OEIS A349636 (permalink):


 A349636

Primes that remain prime when a single "1" digit is inserted between any two adjacent digits.



The initial members of the sequence are:

13, 31, 37, 67, 79, 103, 109, 151, 163, 181, 193, 211, 241, 367, 457, 547, 571, 601, 613, 631, 709, 787, 811, 1117, 1213, 1831, 2017, 2683, 3019, 3319, 3391, 3511, 3517, 3607, 4519, 4999, 6007, 6121, 6151, 6379, 6673, 6871, 6991, 8293, 11119, 11317, 11467, 13171, 13933, 16141, 17167, 18211, 18457, 20101, 21187, 21319, 21817, 22453, 23599, 27241, 32413, 33613, 34543, 36919, 38629, 38917, 41113, 41947, 43759, 44101, 45013, 51109, 54361, 55381, 55813, 58237, 59863, 65731, 67777, 71317, 71713, 71983, 72169, 75193, 81199, 81931, 83221, 85159, 86239, 86743, 89017, 91129, 91303, 94117, 99817, 108907, 110917, 114031, 135019, 139861, 141667, 151687, 171517, 179203, 200191, 211507, 219031, 221941, 224011

As can be seen, these sorts of primes are more frequent compared to OEIS A069246. Of course 27241, my diurnal age today, is also a member of this sequence because  OEIS A069246 is a subsequence of OEIS A349636.

For a related and later post (April 6th 2024) that replicates a lot of the material in this post but does have some new material, go to the post titled "Primes and Nines".

No comments:

Post a Comment