Right-truncatable primes in other bases

Mike Olson
4 min readDec 26, 2023

I’ve been playing with an idea in number theory that I came up with a while ago. I called it “steady primes,” but it turns out that it’s known in the literature as “right-truncatable primes.” These prime numbers have the property that you can drop digits from the right, and the remaining number is still prime. For example, 2393 is a right-truncatable prime, because 239 is prime, 23 is prime and 2 is prime.

I’ve been using my terminology in my prior posts on this, but am switching to the more generally-used terminology, right-truncatable primes, so that these posts are easier to find if people are searching for the term on the internet.

I wondered in one of my earlier posts how right-truncatable primes behaved in other number bases. There are 27 of them in base 10. What about in base 8, base 16, base 29? I wrote a computer program to find right-truncatable primes in any base up to base 36. I used the convention adopted in hexadecimal notation of using alphabetic characters for digits with values greater than 10 in those bases. The letter ‘z’ has a value of 35 in base 36.

What are some non-decimal right-truncatable primes? Here’s a complete list for several different bases:

Base 3:
2122

Base 4:
2333
311

Base 5:
214
2322
3244
34222

Base 6:
21155
21515
215515
2155555
25115
25515
2555
31
35155
515511
515551

Base 7:
23
254
25642
322
3262
5246
5662

Base 8:
211135
21117717
21177
21355
23537
277331
277333
27735
3513313
351717
35713
37333
513
5331
5355533
5735
5773
73717
7531
7533

and so on.

The next question I asked: How many right-truncatable primes are there in every base? I didn’t get an exact answer in every case. The search program found a candidate prime, and then added digits to it, looking up the resulting numbers as new candidates in my precomputed table of primes. That table included only the first one hundred million prime numbers, the last of which is 2,038,074,743. Any candidate number bigger than that was impossible for me to resolve, so I simply noted that there could be more right-truncatable primes along that search path.

I could have computed a bigger table of primes and converted some of the “at least” numbers in the table below to “exactly” numbers, but given how early in the list we lose precision, that table would have to be really big. Base 36 numbers romp through the primes at a furious pace!

With that proviso, the counts in each base are:

base 2: exactly      0
base 3: exactly 1
base 4: exactly 2
base 5: exactly 4
base 6: exactly 11
base 7: exactly 7
base 8: exactly 20
base 9: at least 23
base 10: exactly 27
base 11: at least 28
base 12: at least 61
base 13: at least 56
base 14: at least 147
base 15: at least 126
base 16: at least 145
base 17: at least 140
base 18: at least 240
base 19: at least 275
base 20: at least 398
base 21: at least 530
base 22: at least 600
base 23: at least 422
base 24: at least 697
base 25: at least 1059
base 26: at least 1038
base 27: at least 1009
base 28: at least 1342
base 29: at least 951
base 30: at least 1472
base 31: at least 1368
base 32: at least 1836
base 33: at least 2187
base 34: at least 2416
base 35: at least 2549
base 36: at least 3039

or, graphically, where the X axis is the numeric base and the Y axis is the count of (exact or at-least) right-truncatable primes:

That seems right — jaggy, but generally up and to the right, with a bit of an exponential feel to it. The slope is likely steeper than shown — the “at least” numbers kick in reliably at base 11, so those numbers are almost certainly higher than plotted, especially in the higher bases.

In my first post on this topic, I was struck by the frequency of 3 and 9 digits in the right-truncatable primes in base 10:

Frequency of digits in right-truncatable primes in base 10

Nearly three-quarters of the digits in the 27 right-truncatable decimal primes are 3 or 9. That seemed weird!

I generated histograms for digit frequency for the other bases, from 3 to 36, and eyeballed them for interesting patterns. Nothing struck me as strongly as the 3/9 concentration above, but I did notice that prime bases (base 11, 17, 19 and so on) have nice digit distributions, with pretty much every digit represented. Recall that, since my table of primes didn’t go high enough, these are approximate distributions, not exact. Still, pretty to look at. Here are a couple.

Digit frequency in right-truncatable primes in base 19
Digit frequency in right-truncatable primes in base 31

I think I’ve plumbed this particular topic about as deeply as I want to, so this is likely my last post on the topic. Still, it was a fun way to occupy some vacation hours!

--

--

Mike Olson

Berkeley-based techie with an interest in business. Worried about the world.