Showing posts with label 777. Show all posts
Showing posts with label 777. Show all posts

Saturday, 6 April 2024

Primes and Nines + Primes to Apocalyptic Primes

My diurnal age today is 27397 and this number is prime, marking the end of a 30 day drought of primes according to this daily reckoning. The previous prime, 27367, has a property that marks it for membership in OEIS A124596: primes \(p\) such that \(q-p = 30\), where \(q\) is the next prime after \(p\). So here we are at \(q=27397\).

Now this current prime is rather special because it has a property that marks it for membership in OEIS A215421:


 A215421

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


This means that 927397, 297397, 279397, 273997, 273997 and 273979 are all prime. There is a redundancy in this list of course between 273997 and 273997. Up to 40000, the primes in this sequence are:

7, 19, 37, 41, 199, 239, 311, 587, 661, 941, 967, 1009, 1997, 4993, 4999, 5393, 5651, 6911, 9109, 9397, 9679, 9829, 19417, 20233, 22549, 27397, 29389, 31387, 39989

Clearly, it's been a long while since I experienced a prime with this property and it will be a long while before I experience another. However, what this post is mainly about is how Google's Gemini assisted me in creating an algorithm to generate the initial numbers in this sequence.

I asked Gemini the following question (link):
Can you create a Python program that will generate as output the digit 9 inserted only once, but successively, between every digit of a number that is input. The insertion should take place at the beginning of the number and at the end of the number as well as the between all the digits. For example, if the number 783 was the input then the output would be 9783, 7983, 7893 and 7839.

To which the response was:

Absolutely, here's a Python program that achieves what you described:

This code defines a function insert_digit that takes an integer as input. Here's how it works:

This was very helpful and I was quickly able to incorporate the code into SageMathCell and generate the sequence (permalink). Without the comments, the Python code boils down to this:

def insert_digit(number):
    number_str = str(number)
    inserted_numbers = []
    for i in range(len(number_str) + 1):
        inserted_numbers.append("".join([number_str[:i], "9", number_str[i:]]))
    return inserted_numbers

I find manipulating strings in Python to be quite tedious so I welcomed Gemini doing it for me and the resulting code is straightforward and easy to understand. It can be modified of course using the digits "1", "3" and "7". This generates three new sequences:


 A069246

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



Up to 40000, the initial members of this sequence are (permalink):

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


A215419





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

Up to 40000, the initial members of this sequence are (permalink):

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


 A215420

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



Up to 40000, the initial members of this sequence are (permalink):

3, 19, 97, 433, 487, 541, 691, 757, 853, 1471, 2617, 2953, 4507, 6481, 7351, 7417, 8317, 13177, 31957

Once I spotted the 27241 in OEIS A069246 it occurred to me that I'd probably covered the insertion of 1's in an earlier post and it turned out that indeed I had. On November 2nd 2023, I created a post titled "The Everyone Prime". In that post, I deal with the insertion of 3's and 7's as well but for some reason neglected to mention the insertion of 9's. 

I made 62 posts since that November post so it's not surprising that I sometimes repeat myself but, even though there's redundancy in the two posts, there is some new material including OEIS A215421 (the insertion of 9's) and the use of Google' Gemini to generate Python code.

As a means of adding additional new content to this post, let's use the previous Python code and try inserting the number of the beast, 666, at the beginning of a prime or between the digits of the prime to create a new prime that might called an apocalyptic prime. We'll only look at starting primes in the range from 1 to 999 so that our resulting apocalyptic primes are less than one million.

The following primes (shown with repetition) produce one, two or three apocalyptic primes (runs of three are marked in bold):

11, 17, 29, 29, 43, 43, 53, 53, 83, 97, 97, 101, 101, 103, 103, 109, 109, 109, 113, 113, 127, 131, 139, 149, 157, 167, 167, 167, 173, 179, 191, 191, 193, 193, 211, 223, 229, 229, 233, 233, 241, 241, 251, 263, 263, 269, 271, 277, 277, 281, 283, 293, 307, 311, 313, 331, 337, 347, 349, 353, 353, 383, 397, 397, 401, 419, 421, 431, 433, 439, 449, 461, 467, 487, 499, 503, 541, 541, 557, 577, 587, 593, 593, 599, 599, 607, 607, 619, 643, 643, 647, 647, 683, 683, 701, 709, 709, 727, 733, 739, 751, 751, 757, 769, 773, 787, 811, 821, 823, 823, 823, 827, 829, 829, 829, 839, 853, 857, 883, 883, 887, 919, 929, 929, 937, 937, 941, 947, 953, 977, 983

Here are the 125 apocalyptic primes that they produce (permalink).

16661, 26669, 46663, 56663, 66617, 66629, 66643, 66653, 66683, 66697, 96667, 106661, 106663, 106669, 116663, 146669, 166601, 166603, 166609, 166613, 166627, 166631, 166657, 166667, 166679, 166693, 196661, 196663, 216661, 226663, 226669, 246661, 256661, 266633, 266641, 266663, 266671, 266677, 266681, 266683, 296663, 316661, 316663, 336667, 346667, 346669, 356663, 366607, 366631, 366683, 366697, 396667, 406661, 426661, 466619, 466649, 486667, 496669, 506663, 546661, 566677, 566693, 586667, 596663, 596669, 616669, 666109, 666139, 666167, 666173, 666191, 666229, 666233, 666269, 666277, 666353, 666431, 666433, 666439, 666461, 666467, 666541, 666557, 666599, 666607, 666643, 666647, 666683, 666727, 666733, 666751, 666769, 666773, 666811, 666821, 666823, 666829, 666857, 666929, 666937, 666983, 706661, 706669, 756667, 766609, 766639, 766651, 766687, 826663, 826667, 826669, 866623, 866629, 866639, 866653, 866683, 886663, 886667, 926669, 936667, 946661, 946667, 966619, 966653, 966677

It can be noted that 607, 643 and 683 produce apocalyptic primes that contain four consecutive sixes, namely 666607, 666643, 666647 and 666683 respectively. Of course, these are not the only apocalyptic primes because those above were generated using initial primes. If we begin with either composite or prime numbers between 1 and 999, then 203 apocalyptic primes are generated (permalink). So 78 composite numbers will also generate these types of primes, beginning with 1 --> 6661 and ending with 979 --> 976669 (neither 1 nor 979 = 11 x 89 are prime). The algorithm is easily modified to accommodate other digit sequences like 777 (permalink).

Sunday, 6 June 2021

26362: Another Special Palindrome

The day that I turned 26262 days old I dedicated a post to the number and titled it 26262: A Special Palindrome. That was on February 21st 2021. Today I'm enjoying the next successive palindromic day, having turned 26362 days old. 

Now this is a somewhat unusual palindrome in that it is not a member of OEIS A067030


A067030



Numbers \(n\) that are of the form \(k\) + reverse(\(k\)) for at least one \(k\).



Let's be clear firstly that such numbers are not common. The 1000th such number is 38772 which translates to a percentage density of less than 2.6%. The first such numbers are:
0, 2, 4, 6, 8, 10, 11, 12, 14, 16, 18, 22, 33, 44, 55, 66, 77, 88, 99, 101, 110, 121, 132, 141, 143, 154, 161, 165, 176, 181, 187, 198, 201, 202, 221, 222, 241, 242, 261, 262, 281, 282, 302, 303, 322, 323, 342, 343, 362, 363, 382, 383, 403, 404, 423, 424, 443 
Of these first 56 members of the sequence, 29 (more than 50%) are palindromic. This is not surprising because most numbers, under the repeated Reverse and Add operation, lead to a palindrome. 196 is the first number that apparently does not. Let's look at the palindromes not belonging to this sequence: 

131, 151, 171, 191, 212, 232, 252, 272, 292, 313, 333, 353, 373, 393, 434

All of them lead to palindromes under Reverse and Add, as shown below:

131 requires 1 steps to reach the palindrome 262
151 requires 2 steps to reach the palindrome 505
171 requires 2 steps to reach the palindrome 585
191 requires 4 steps to reach the palindrome 2552
212 requires 1 steps to reach the palindrome 424
232 requires 1 steps to reach the palindrome 464
252 requires 2 steps to reach the palindrome 909
272 requires 2 steps to reach the palindrome 989
292 requires 8 steps to reach the palindrome 233332
313 requires 1 steps to reach the palindrome 626
333 requires 1 steps to reach the palindrome 666
353 requires 3 steps to reach the palindrome 4444
373 requires 4 steps to reach the palindrome 9559
393 requires 4 steps to reach the palindrome 9339
434 requires 1 steps to reach the palindrome 868

26362 as it turns out is a member of OEIS A070001:


 A070001

Palindromes whose 'Reverse and Add' trajectory (presumably) does not lead to another palindrome.

 The initial members of this sequence are:

4994, 8778, 9999, 11811, 19591, 22822, 23532, 23632, 23932, 24542, 24742, 24842, 24942, 26362, 27372, 29792, 29892, 33933, 34543, 34743, 34943, 39493, 44744, 46064, 46164, 46364, 46564, 46964, 47274, 47574, 48284, 48584, 48684, 48884

These palindromes are not regarded as potential Lychrel numbers because they are already palindromes and some of them are the result or end point of \(k\) + reverse(\(k)\) iterations. However, some are not and these, I think, deserve special consideration:

19591, 23532, 23932, 24542, 24742, 24942, 26362, 27372, 29792, 33933, 34543, 34743, 34943, 39493, 44744, 46164, 46364, 46564, 46964, 47574, 48584

So 26362 is only the 7th palindrome to have the simultaneous property that:

  • it cannot be derived from \(k\) + reverse(\(k\)) for one or more values of \(k\)
  • its Reverse and Add trajectory (presumably) does not lead to another palindrome
There already two sevens associated with the number because \(7^2\) is a factor, so we have a lucky triple 7.


This is not the first time that I've written about palindromic numbers. Apart from my 26262: A Special Palindrome post, I've written about:
In researching this post, I came across a category of primes known as Palindromic Wing Primes or PMPs defined as "numbers that are primes, palindromic in base 10, and consisting of one central digit surrounded by two wings having an equal amount of identical digits and different from the central one". Examples are:

101
99999199999
333333313333333
7777777777772777777777777
11111111111111111111111111111111411111111111111111111111111111111

Some of these primes are regarded as potential Lychrel candidates and are listed in OEIS A320516 (with the rule that palindromes are ineligible being relaxed):


 A320516

Palindromic wing primes that are also Lychrel candidates.        
    

Initial members are:
7774777, 777767777, 77777677777, 99999199999, 1111118111111, 7777774777777, 111111181111111, 333333373333333, 77777777677777777, 99999999299999999, 9999999992999999999, 33333333333733333333333, 77777777777677777777777, 333333333333373333333333333

More information about PWPs can be found here. Palindromes and any numbers can be tested for Lychrel candidature using SageMathCell. A permalink is attached to the screenshoot in Figure 1.

Figure 1: permalink