Showing posts with label truncatable. Show all posts
Showing posts with label truncatable. Show all posts

Thursday, 12 January 2023

Rotate and Add

26947 is a prime, in fact it's a left truncatable prime. This means that with successive removal of digits from the left, the resulting number is still prime. Thus we have 6947, 947, 47 and 7 all being prime. The number was brought to my attention because it represents my diurnal age today: 12th January 2023. Coincidentally if we write this date as 12-1-2023 and then concatenate the digits to form 1212023, this number too is prime.

However, 26947 is also of interest in connection to a so-called rotate and add operation that can be applied to any integer number. If the number has an even number of digits, let's say 1234, then we divide the number into two parts of equal length (12|34) and swap the two parts (34|12) to form 3412. If the number has an odd number of digits, let's say 12345, then we leave the central digit unchanged (12|3|45) but swap the left and right hand parts (45|3|12) to form 45312.

Let's consider primes in the range up to 1000. How many of them will remain prime under this operation. These are the primes that remain prime:

229, 239, 241, 257, 269, 271, 277, 281, 439, 443, 463, 467, 479, 499, 613, 641, 653, 661, 673, 677, 683, 691, 811, 823, 839, 863, 881

Let's take 229 as an example. The operation leads to its rotation (where it becomes 922) and its addition to its rotated form (229 + 922) leads to 1151 which is prime. Primes such as these form OEIS A086002:


 A086002

Primes which when added to their own rotation yield a prime.     
                     


26947 is one such prime because its rotation (47926) and its addition to this rotation (26947 + 47926) generates the prime 74873. However, when the operation is applied to this new prime, the result is still a prime. This is because 74873 + 73874 = 148747 which is prime. Primes such as this are much rarer and constitute OEIS A086003:


 A086003

Primes which remain prime after one and after two applications of the rotate-and-add operation of A086002.



The initial members of this sequence are:

271, 281, 10853, 10903, 10939, 12917, 12919, 16603, 16673, 16823, 16843, 18671, 18911, 18913, 20929, 22817, 22907, 24907, 26813, 26833, 26903, 26947, 28661, 28901, 28921, 30809, 30829, 32831, 32917, 32941, 34939, 36653, 36913, 38651

Unfortunately, if we repeat the process, 26947 does not survive but other numbers do and these constitute OEIS A086004


 A086004

Primes which remain prime after one and after two and after three applications of the rotate-and-add operation of A086002.



The initial members of this sequence are (permalink):

12917, 12919, 18911, 18913, 22907, 24907, 26903, 28901, 1088063, 1288043, 1408031, 1428029, 1528019, 100083679, 100280419, 100283849, 100483847, 100692793, 100880413, 101080159, 101283839, 101683093, 101683663, 102080149

None of the primes listed above survive another round but there are larger primes that do and these constitute OEIS A261458:


 A261458

Primes which remain prime after one, two, three and four applications of the rotate-and-add operation of A086002.



The initial members of this sequence are:

10010905789, 10028905771, 10036905763, 10050905749, 10056905743, 10060905739, 10070905729, 10080905719, 10092905707, 10098905701, 10102905697, 10106905693, 10108905691, 10112905687, 10130905669, 10160905639, 10172905627, 10176905623, 10188905611, 10190905609 

In general, it can be noted that rotation and addition of primes with even numbers of digits never yields a prime. This can be seen, using \(ab\) as an example because the rotation \(ba\) and addition generates \(10a+b+10b+a=11a+11b=11 \times (a+b)\) which is composite.

As far as I know, no primes have been found that survive five applications of the operation and according the the comments to OEIS A261458 six applications can never generate a prime.

The rotate and add operation of course does not need to be confined to primes. For example. we could consider semiprimes that remain semiprimes under one, two, three etc. applications of the operation. Such an investigation could form the basis of a future post.

Tuesday, 15 March 2022

Truncatable Primes

I've not dedicated a post to truncatable primes since I started this blog in 2015 but I was prompted to do so because one of the properties associated with my diurnal age today, 26644, is that it's a member of OEIS A346662:


  A346662

Number of \(n\)-digit left- or right-truncatable primes with no consecutive zero digits.   


The number of members of this sequence is finite and consists of:

4, 16, 76, 300, 955, 2648, 6402, 14339, 28684, 53450, 91284, 147064, 221301, 319067, 433227, 567565, 700765, 834464, 947055, 1050886, 1114368, 1157526, 1150645, 1117265, 1044757, 963722, 855804, 753172, 633786, 528122, 426328, 339866, 264078, 202013, 150330, 111055, 78996, 56123, 38874, 26644, 17944, 11898, 7878, 4945, 3255, 2024, 1323, 764, 464, 286, 158, 77, 40, 26, 14, 5, 5, 4, 1, 1

The sequence member 26644 corresponds to \(n\)=40. Thus there are 26644 40-digit primes that are left-or right-truncatable. The reason for having no consecutive zero digits is that, without this restriction, suitable primes could be made indefinitely long. The comments to the OEIS entry are as follows:
A left- or right-truncatable prime is a prime number from which one digit at a time may be removed from the left or right end until a single-digit prime is reached, with each digit removal resulting in a prime. There exists only one such 60-digit prime: 
202075909708030901050930450609080660821035604908735717137397 
Since it cannot be extended, there are no such primes with more than 60 digits, so a(60)=1 is the final term of the sequence.

The OEIS sequence listing these primes is A347864:


 A347864

Left-or right-truncatable primes, restricted to one consecutive zero.      

The sequence begins as follows:

2, 3, 5, 7, 13, 17, 23, 29, 31, 37, 43, 47, 53, 59, 67, 71, 73, 79, 83, 97, 103, 107, 113, 131, 137, 139, 167, 173, 179, 197, 223, 229, 233, 239, 271, 283, 293, 307, 311, 313, 317, 331, 337, 347, 353, 359, 367, 373, 379, 383, 397, 431, 433, 439, 443, 467, 479, 503 

The OEIS comments state that:

There are 16,484,138 primes in this list, in total. The largest one has 60 digits and there is only one of that length.

Generally however, when considering truncatable primes, zeros are not allowed at all. One such OEIS sequence with this restriction is OEIS A137812:

 
 A137812

Left- or right-truncatable primes.                                                     


This finite sequence begins as follows:

2, 3, 5, 7, 13, 17, 23, 29, 31, 37, 43, 47, 53, 59, 67, 71, 73, 79, 83, 97, 113, 131, 137, 139, 167, 173, 179, 197, 223, 229, 233, 239, 271, 283, 293, 311, 313, 317, 331, 337, 347, 353, 359, 367, 373, 379, 383, 397, 431, 433, 439, 443, 467, 479, 523, 547, 571, ...

For example, 313 --> 13 --> 3 or 313 --> 31 --> 3. Another example is 443 --> 43 --> 3. Note that this sequence lists the actual primes and not the number of possible \(n\)-digit primes. The OEIS comments state that:
Repeatedly removing a digit from either the left or right produces only primes. There are 149,677 terms in this sequence, ending with a 31 digit prime: 
8939662423123592347173339993799

In the previous process, we have the option of successively moving one digit from the left OR right but different constraints can be imposed. Three of these are:

  1. digits can only be removed from the left (this produces the left-truncatable primes)
  2. digits can only be removed from the right (this produces the right-truncatable primes)
  3. digits must be removed in pairs (one from the left and one from the right, simultaneously)
The left-truncatable primes comprise OEIS  A024785


 A024785

Left-truncatable primes: every suffix is prime and no digits are zero.      


An example is 1223 because 1223, 223, 23 and 3 are all prime. There are 4620 such primes, the largest being 357686312646216567629137. The sequence begins:

2, 3, 5, 7, 13, 17, 23, 37, 43, 47, 53, 67, 73, 83, 97, 113, 137, 167, 173, 197, 223, 283, 313, 317, 337, 347, 353, 367, 373, 383, 397, 443, 467, 523, 547, 613, 617, 643, 647, 653, 673, 683, 743, 773, 797, 823, 853, 883, 937, 947, 953, 967, 983, 997, 1223, ...

The right-truncatable primes comprise OEIS A024770:


 A024770

Right-truncatable primes: every prefix is prime.                                                   


An example is 31193 because 31193, 3119, 311, 31 and 3 are all prime. There are 83 such primes, the largest being 73939133. The sequence begins:

2, 3, 5, 7, 23, 29, 31, 37, 53, 59, 71, 73, 79, 233, 239, 293, 311, 313, 317, 373, 379, 593, 599, 719, 733, 739, 797, 2333, 2339, 2393, 2399, 2939, 3119, 3137, 3733, 3739, 3793, 3797, 5939, 7193, 7331, 7333, 7393, 23333, 23339, 23399, 23993, 29399, 31193, ...

There are 15 primes that are both left- and right-truncatable and form OEIS A020994:
2, 3, 5, 7, 23, 37, 53, 73, 313, 317, 373, 797, 3137, 3797, 739397

The bi-truncatable primes comprise OEIS A077390:


  A077390

Primes which leave primes at every step if most significant digit and least significant digit are deleted until a one digit or two digit prime is obtained.

An example is 21313 because 21313, 131 and 3 all are primes. The sequence begins:

2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 127, 131, 137, 139, 151, 157, 173, 179, 223, 227, 229, 233, 239, 251, 257, 271, 277, 331, 337, 353, 359, 373, 379, 421, 431, 433, 439, 457, 479, 521, 523, 557, 571, 577, 631, 653, 659, ...

The OEIS comments state that:
There are exactly 920,720,315 such primes, the largest being 9161759674286961988443272139114537477768682563429152377117139 1111313737919133977331737137933773713713973.

There are exactly 331,780,864 odd length primes and 588,939,451 even length primes, the largest odd length prime being

7228828176786792552781668926755667258635743361825711373791931117197999133917737137399993737111177