Saturday, 10 August 2024

Radix Economy

In a coffee shop this afternoon, I was reading an interesting article in Quanta Magazine titled How Base 3 Computing Beats Binary. I like the graphic also that began the article and which I've reproduced in Figure 1.


Figure 1: source

The article introduces the notion of "radix economy" that is explained as follows:

The hallmark feature of ternary notation is that it’s ruthlessly efficient. With two binary bits, you can represent four numbers. Two “trits” — each with three different states — allow you to represent nine different numbers. A number that requires 42 bits would need only 27 trits.

If a three-state system is so efficient, you might imagine that a four-state or five-state system would be even more so. But the more digits you require, the more space you’ll need. It turns out that ternary is the most economical of all possible integer bases for representing big numbers.

To see why, consider an important metric that tallies up how much room a system will need to store data. You start with the base of the number system, which is called the radix, and multiply it by the number of digits needed to represent some large number in that radix. For example, the number 100,000 in base 10 requires six digits. Its “radix economy” is therefore 10 × 6 = 60. In base 2, the same number requires 17 digits, so its radix economy is 2 × 17 = 34. And in base 3, it requires 11 digits, so its radix economy is 3 × 11 = 33. For large numbers, base 3 has a lower radix economy than any other integer base.

This Wikipedia article explains it in more formal terms for a number \(N\):$$ \text{radix economy of } N =b \lfloor \log_b(N)+1 \rfloor $$For large \(N\) we can thus write:$$ \begin{align} \text{radix economy of } N &\approx b \log_b(N) \\ &= \frac{b}{ln \,(b)} ln \,(N) \end{align}$$Using the number 123456789 as an example, the radix efficiency for integer bases from 3 to 16 is shown in Figure 2.

Figure 2: base 3 is best

The Quanta article goes on to say that:

In addition to its numerical efficiency, base 3 offers computational advantages. It suggests a way to reduce the number of queries needed to answer questions with more than two possible answers. A binary logic system can only answer “yes” or “no.” So if you’re comparing two numbers, x and y, to find out which is larger, you might first ask the computer “Is x less than y?” If the answer is no, you need a second query: “Is x equal to y?” If the answer is yes, then they’re equal; if the answer is no, then y is less than x. A system using ternary logic can give one of three answers. Because of this, it requires only one query: “Is x less than, equal to, or greater than y?”

And finally, also quoting from the article:

Surprisingly, if you allow a base to be any real number, and not just an integer, then the most efficient computational base is the irrational number e.

The table in Figure 2 looks as shown in Figure 3 when we add "e" to the list of bases.

Figure 3: e is best

Representing numbers using "e" as the number base is the stuff of a future post perhaps but here is a link to how to go about it. 

What's Special About 27527?

I've written before about primes whose digits are all prime in two earlier posts:

It's time to revisit this topic because, as I count my diurnal age, I have 27527 coming up in four days time and it is such a prime. These primes are rare indeed and need to be celebrated. Here is the list of the 124 such primes up to 40000 (permalink):

2, 3, 5, 7, 23, 37, 53, 73, 223, 227, 233, 257, 277, 337, 353, 373, 523, 557, 577, 727, 733, 757, 773, 2237, 2273, 2333, 2357, 2377, 2557, 2753, 2777, 3253, 3257, 3323, 3373, 3527, 3533, 3557, 3727, 3733, 5227, 5233, 5237, 5273, 5323, 5333, 5527, 5557, 5573, 5737, 7237, 7253, 7333, 7523, 7537, 7573, 7577, 7723, 7727, 7753, 7757, 22273, 22277, 22573, 22727, 22777, 23227, 23327, 23333, 23357, 23537, 23557, 23753, 23773, 25237, 25253, 25357, 25373, 25523, 25537, 25577, 25733, 27253, 27277, 27337, 27527, 27733, 27737, 27773, 32233, 32237, 32257, 32323, 32327, 32353, 32377, 32533, 32537, 32573, 33223, 33353, 33377, 33533, 33577, 33757, 33773, 35227, 35257, 35323, 35327, 35353, 35527, 35533, 35537, 35573, 35753, 37223, 37253, 37273, 37277, 37337, 37357, 37537, 37573


As can be seen, it's been a while since the last such prime (27337) and it will be quite a while to the next (27733). Furthermore, 27527 has the added property that the sum of its digits (23) is also prime. There are only 61 of these numbers in the range up to 40000. They are (permalink):

2, 3, 5, 7, 23, 223, 227, 337, 353, 373, 557, 577, 733, 757, 773, 2333, 2357, 2377, 2557, 2753, 2777, 3253, 3257, 3323, 3527, 3727, 5233, 5237, 5273, 5323, 5527, 7237, 7253, 7523, 7723, 7727, 22573, 23327, 25237, 25253, 25523, 27253, 27527, 32233, 32237, 32257, 32323, 32327, 33223, 33353, 33377, 33533, 33773, 35227, 35353, 35533, 35537, 35573, 35753, 37223, 37337

Figure 1 shows the distribution of these primes:


Figure 1: permalink

Not of all of these prime sums of digits have digits that are all prime. 27527 with its digit sum of 23 qualifies but others don't. In fact there are only 15 numbers with digit sums that are prime and that have all of the digits of this sum prime. These are (permalink):

2, 3, 5, 7, 23, 223, 2777, 7727, 27527, 33377, 33773, 35537, 35573, 35753, 37337

Similarly, not all of these previously listed primes have a digital arithmetic root that is prime. However, 27527 does because its sum of digits (23) leads to a root of 5. There are only 19 such primes in the range up to 40000. They are (permalink):

2, 3, 5, 7, 23, 223, 227, 353, 2333, 2777, 3323, 7727, 27527, 33377, 33773, 35537, 35573, 35753, 37337

So in summary 27527 is special because:
  • it is prime: 27527
  • all its digits are prime: 2, 5 and 7
  • the sum of its digits is prime: 23
  • the digits of its sum of digits are prime: 2 and 3
  • its arithmetic digital root is prime: 5
All these properties fall within the realm of recreational Mathematics because they are base dependent but nonetheless they are interesting to numberphiles who find number properties of any type in any base to be fascinating.

Wednesday, 7 August 2024

Additive Fibonacci-like Numbers

Consider all two digit numbers from 10 to 99 and use these as the seed digits that will generate a third digit by ADDITION of the two digits and by then finding the DIGITAL ROOT of the resultant sum. Here are the 90 starting numbers.

10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99

These 90 two digit numbers will generate another 90 three digit numbers. These are:

101, 112, 123, 134, 145, 156, 167, 178, 189, 191, 202, 213, 224, 235, 246, 257, 268, 279, 281, 292, 303, 314, 325, 336, 347, 358, 369, 371, 382, 393, 404, 415, 426, 437, 448, 459, 461, 472, 483, 494, 505, 516, 527, 538, 549, 551, 562, 573, 584, 595, 606, 617, 628, 639, 641, 652, 663, 674, 685, 696, 707, 718, 729, 731, 742, 753, 764, 775, 786, 797, 808, 819, 821, 832, 843, 854, 865, 876, 887, 898, 909, 911, 922, 933, 944, 955, 966, 977, 988, 999

These in turn will produce 90 four digit numbers. These are:

1011, 1123, 1235, 1347, 1459, 1562, 1674, 1786, 1898, 1911, 2022, 2134, 2246, 2358, 2461, 2573, 2685, 2797, 2819, 2922, 3033, 3145, 3257, 3369, 3472, 3584, 3696, 3718, 3821, 3933, 4044, 4156, 4268, 4371, 4483, 4595, 4617, 4729, 4832, 4944, 5055, 5167, 5279, 5382, 5494, 5516, 5628, 5731, 5843, 5955, 6066, 6178, 6281, 6393, 6415, 6527, 6639, 6742, 6854, 6966, 7077, 7189, 7292, 7314, 7426, 7538, 7641, 7753, 7865, 7977, 8088, 8191, 8213, 8325, 8437, 8549, 8652, 8764, 8876, 8988, 9099, 9112, 9224, 9336, 9448, 9551, 9663, 9775, 9887, 9999

These in turn will produce 90 five digit numbers. These are:

10112, 11235, 12358, 13472, 14595, 15628, 16742, 17865, 18988, 19112, 20224, 21347, 22461, 23584, 24617, 25731, 26854, 27977, 28191, 29224, 30336, 31459, 32573, 33696, 34729, 35843, 36966, 37189, 38213, 39336, 40448, 41562, 42685, 43718, 44832, 45955, 46178, 47292, 48325, 49448, 50551, 51674, 52797, 53821, 54944, 55167, 56281, 57314, 58437, 59551, 60663, 61786, 62819, 63933, 64156, 65279, 66393, 67426, 68549, 69663, 70775, 71898, 72922, 73145, 74268, 75382, 76415, 77538, 78652, 79775, 80887, 81911, 82134, 83257, 84371, 85494, 86527, 87641, 88764, 89887, 90999, 91123, 92246, 93369, 94483, 95516, 96639, 97753, 98876, 99999

Forgetting about the original two digit numbers, let's group all the three, four and five digits number together so that we have 270 numbers. These are:

101, 112, 123, 134, 145, 156, 167, 178, 189, 191, 202, 213, 224, 235, 246, 257, 268, 279, 281, 292, 303, 314, 325, 336, 347, 358, 369, 371, 382, 393, 404, 415, 426, 437, 448, 459, 461, 472, 483, 494, 505, 516, 527, 538, 549, 551, 562, 573, 584, 595, 606, 617, 628, 639, 641, 652, 663, 674, 685, 696, 707, 718, 729, 731, 742, 753, 764, 775, 786, 797, 808, 819, 821, 832, 843, 854, 865, 876, 887, 898, 909, 911, 922, 933, 944, 955, 966, 977, 988, 999, 1011, 1123, 1235, 1347, 1459, 1562, 1674, 1786, 1898, 1911, 2022, 2134, 2246, 2358, 2461, 2573, 2685, 2797, 2819, 2922, 3033, 3145, 3257, 3369, 3472, 3584, 3696, 3718, 3821, 3933, 4044, 4156, 4268, 4371, 4483, 4595, 4617, 4729, 4832, 4944, 5055, 5167, 5279, 5382, 5494, 5516, 5628, 5731, 5843, 5955, 6066, 6178, 6281, 6393, 6415, 6527, 6639, 6742, 6854, 6966, 7077, 7189, 7292, 7314, 7426, 7538, 7641, 7753, 7865, 7977, 8088, 8191, 8213, 8325, 8437, 8549, 8652, 8764, 8876, 8988, 9099, 9112, 9224, 9336, 9448, 9551, 9663, 9775, 9887, 9999, 10112, 11235, 12358, 13472, 14595, 15628, 16742, 17865, 18988, 19112, 20224, 21347, 22461, 23584, 24617, 25731, 26854, 27977, 28191, 29224, 30336, 31459, 32573, 33696, 34729, 35843, 36966, 37189, 38213, 39336, 40448, 41562, 42685, 43718, 44832, 45955, 46178, 47292, 48325, 49448, 50551, 51674, 52797, 53821, 54944, 55167, 56281, 57314, 58437, 59551, 60663, 61786, 62819, 63933, 64156, 65279, 66393, 67426, 68549, 69663, 70775, 71898, 72922, 73145, 74268, 75382, 76415, 77538, 78652, 79775, 80887, 81911, 82134, 83257, 84371, 85494, 86527, 87641, 88764, 89887, 90999, 91123, 92246, 93369, 94483, 95516, 96639, 97753, 98876, 99999

Viewed as a Fibonacci-like sequence, the sequence of digits will eventually cycle. Take 27977 as an example. The progression is:$$2, 7, 9, 7, 7, 5, 3, 8, 2, 1, 3, 4, 7, 2, 9, 2, 2, 4, 6, 1, 7, 8, 6, 5, 2, 7, 9, 7, 7, \dots $$An alternative to this progression of digits is to determine the arithmetical digital root of the cumulative sum of digits and use this as the next digit. Here is a permalink that will generate this sequence of 270 numbers. Here are the numbers:

101, 112, 123, 134, 145, 156, 167, 178, 189, 191, 202, 213, 224, 235, 246, 257, 268, 279, 281, 292, 303, 314, 325, 336, 347, 358, 369, 371, 382, 393, 404, 415, 426, 437, 448, 459, 461, 472, 483, 494, 505, 516, 527, 538, 549, 551, 562, 573, 584, 595, 606, 617, 628, 639, 641, 652, 663, 674, 685, 696, 707, 718, 729, 731, 742, 753, 764, 775, 786, 797, 808, 819, 821, 832, 843, 854, 865, 876, 887, 898, 909, 911, 922, 933, 944, 955, 966, 977, 988, 999, 1012, 1124, 1236, 1348, 1451, 1563, 1675, 1787, 1899, 1912, 2024, 2136, 2248, 2351, 2463, 2575, 2687, 2799, 2812, 2924, 3036, 3148, 3251, 3363, 3475, 3587, 3699, 3712, 3824, 3936, 4048, 4151, 4263, 4375, 4487, 4599, 4612, 4724, 4836, 4948, 5051, 5163, 5275, 5387, 5499, 5512, 5624, 5736, 5848, 5951, 6063, 6175, 6287, 6399, 6412, 6524, 6636, 6748, 6851, 6963, 7075, 7187, 7299, 7312, 7424, 7536, 7648, 7751, 7863, 7975, 8087, 8199, 8212, 8324, 8436, 8548, 8651, 8763, 8875, 8987, 9099, 9112, 9224, 9336, 9448, 9551, 9663, 9775, 9887, 9999, 10124, 11248, 12363, 13487, 14512, 15636, 16751, 17875, 18999, 19124, 20248, 21363, 22487, 23512, 24636, 25751, 26875, 27999, 28124, 29248, 30363, 31487, 32512, 33636, 34751, 35875, 36999, 37124, 38248, 39363, 40487, 41512, 42636, 43751, 44875, 45999, 46124, 47248, 48363, 49487, 50512, 51636, 52751, 53875, 54999, 55124, 56248, 57363, 58487, 59512, 60636, 61751, 62875, 63999, 64124, 65248, 66363, 67487, 68512, 69636, 70751, 71875, 72999, 73124, 74248, 75363, 76487, 77512, 78636, 79751, 80875, 81999, 82124, 83248, 84363, 85487, 86512, 87636, 88751, 89875, 90999, 91124, 92248, 93363, 94487, 95512, 96636, 97751, 98875, 99999

Let's take 26875 as an example. We begin with 26 as our seed number and then proceed thus: $$ \begin{align} 26 \text{ has digit sum } 8 &\rightarrow 268 \\ 268 \text{ has digit sum } 16 \equiv 7 &\rightarrow 2687 \\ 2687 \text{ has digit sum } 23 \equiv 5 &\rightarrow 26875 \end{align} $$The three digit numbers are the same as earlier but the differences arise in the four and five digit numbers. Let's compare the previous cumulative results with the seed number 26 again but using the earlier two digit approach:$$ \begin{align} 26 \text{ has digit sum } 8 &\rightarrow 268 \\ 68 \text{ has digit sum } 14 \equiv 5 &\rightarrow 2685 \\ 85 \text{ has digit sum } 13 \equiv 4 &\rightarrow 26854 \end{align} $$

Subtractive Fibonacci-like Numbers

Consider all two digit numbers from 10 to 99 and use these as the seed digits that will generate a third number NOT by ADDITION of the two digits but by SUBTRACTION, subtracting the smaller digit from the larger when they are different. This ensures that the result is always positive or zero. Taking the absolute value of the result is another way to regard it. Here are the 90 numbers.

10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99

These 90 two digit numbers will generate another 90 three digit numbers. These are:

101, 110, 121, 132, 143, 154, 165, 176, 187, 198, 202, 211, 220, 231, 242, 253, 264, 275, 286, 297, 303, 312, 321, 330, 341, 352, 363, 374, 385, 396, 404, 413, 422, 431, 440, 451, 462, 473, 484, 495, 505, 514, 523, 532, 541, 550, 561, 572, 583, 594, 606, 615, 624, 633, 642, 651, 660, 671, 682, 693, 707, 716, 725, 734, 743, 752, 761, 770, 781, 792, 808, 817, 826, 835, 844, 853, 862, 871, 880, 891, 909, 918, 927, 936, 945, 954, 963, 972, 981, 990

These in turn will spawn another 90 numbers. These are:

1011, 1101, 1211, 1321, 1431, 1541, 1651, 1761, 1871, 1981, 2022, 2110, 2202, 2312, 2422, 2532, 2642, 2752, 2862, 2972, 3033, 3121, 3211, 3303, 3413, 3523, 3633, 3743, 3853, 3963, 4044, 4132, 4220, 4312, 4404, 4514, 4624, 4734, 4844, 4954, 5055, 5143, 5231, 5321, 5413, 5505, 5615, 5725, 5835, 5945, 6066, 6154, 6242, 6330, 6422, 6514, 6606, 6716, 6826, 6936, 7077, 7165, 7253, 7341, 7431, 7523, 7615, 7707, 7817, 7927, 8088, 8176, 8264, 8352, 8440, 8532, 8624, 8716, 8808, 8918, 9099, 9187, 9275, 9363, 9451, 9541, 9633, 9725, 9817, 9909

These in turn will spawn another 90 numbers. These are:

10110, 11011, 12110, 13211, 14312, 15413, 16514, 17615, 18716, 19817, 20220, 21101, 22022, 23121, 24220, 25321, 26422, 27523, 28624, 29725, 30330, 31211, 32110, 33033, 34132, 35231, 36330, 37431, 38532, 39633, 40440, 41321, 42202, 43121, 44044, 45143, 46242, 47341, 48440, 49541, 50550, 51431, 52312, 53211, 54132, 55055, 56154, 57253, 58352, 59451, 60660, 61541, 62422, 63303, 64220, 65143, 66066, 67165, 68264, 69363, 70770, 71651, 72532, 73413, 74312, 75231, 76154, 77077, 78176, 79275, 80880, 81761, 82642, 83523, 84404, 85321, 86242, 87165, 88088, 89187, 90990, 91871, 92752, 93633, 94514, 95413, 96330, 97253, 98176, 99099

Let's forget about our two digit starting numbers and consider only the resulting three, four and five digit numbers. Grouping them all together we have the following 270 member sequence:

101, 110, 121, 132, 143, 154, 165, 176, 187, 198, 202, 211, 220, 231, 242, 253, 264, 275, 286, 297, 303, 312, 321, 330, 341, 352, 363, 374, 385, 396, 404, 413, 422, 431, 440, 451, 462, 473, 484, 495, 505, 514, 523, 532, 541, 550, 561, 572, 583, 594, 606, 615, 624, 633, 642, 651, 660, 671, 682, 693, 707, 716, 725, 734, 743, 752, 761, 770, 781, 792, 808, 817, 826, 835, 844, 853, 862, 871, 880, 891, 909, 918, 927, 936, 945, 954, 963, 972, 981, 990, 1011, 1101, 1211, 1321, 1431, 1541, 1651, 1761, 1871, 1981, 2022, 2110, 2202, 2312, 2422, 2532, 2642, 2752, 2862, 2972, 3033, 3121, 3211, 3303, 3413, 3523, 3633, 3743, 3853, 3963, 4044, 4132, 4220, 4312, 4404, 4514, 4624, 4734, 4844, 4954, 5055, 5143, 5231, 5321, 5413, 5505, 5615, 5725, 5835, 5945, 6066, 6154, 6242, 6330, 6422, 6514, 6606, 6716, 6826, 6936, 7077, 7165, 7253, 7341, 7431, 7523, 7615, 7707, 7817, 7927, 8088, 8176, 8264, 8352, 8440, 8532, 8624, 8716, 8808, 8918, 9099, 9187, 9275, 9363, 9451, 9541, 9633, 9725, 9817, 9909, 10110, 11011, 12110, 13211, 14312, 15413, 16514, 17615, 18716, 19817, 20220, 21101, 22022, 23121, 24220, 25321, 26422, 27523, 28624, 29725, 30330, 31211, 32110, 33033, 34132, 35231, 36330, 37431, 38532, 39633, 40440, 41321, 42202, 43121, 44044, 45143, 46242, 47341, 48440, 49541, 50550, 51431, 52312, 53211, 54132, 55055, 56154, 57253, 58352, 59451, 60660, 61541, 62422, 63303, 64220, 65143, 66066, 67165, 68264, 69363, 70770, 71651, 72532, 73413, 74312, 75231, 76154, 77077, 78176, 79275, 80880, 81761, 82642, 83523, 84404, 85321, 86242, 87165, 88088, 89187, 90990, 91871, 92752, 93633, 94514, 95413, 96330, 97253, 98176, 99099

The sequence will continue indefinitely and what drew my attention to these types of numbers was the number associated with my diurnal age today, 27520. I noticed that it almost qualified because 7 - 2 = 5, 7 - 5 = 2 but 5 - 2 does not produce the required final digit of 3. However, in three more days it will when my diurnal age reaches 27523 days. The next number in the sequence is 28624 which is some three years away. Such numbers are certainly not frequent so they deserve to be given some attention.

Viewed as a Fibonacci-like sequence of numbers, the sequences all settle down to a repetitive \(0, n, n\) pattern where \(n\) is a digit between 1 and 9. For example, 27523 becomes:$$2, 7, 5, 2, 3, 1, 2, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, \dots$$The fact that the absolute value of the repeated subtraction of the two digits cannot produce numbers greater than 9 ensures eventual repetition. Subtraction aside, there are similar sequences to explore like adding the first two digits together to produce a third number that is not the sum of the first two, as in the Fibonacci sequence, but the DIGITAL ROOT of the number. For example:$$ \begin{align} 27 &\rightarrow 279 \\279 &\rightarrow 2797 \text{ since } 9 + 7 = 16 \rightarrow 7 \\ 2797 &\rightarrow 27977 \end{align} $$This sequence will be examined in my next post.

Monday, 5 August 2024

Forming Digit Equations: A Game

Source

It occurred to me how forming digit equations from five digits might make for an interesting game. After all, Wordle consists of guessing the five letters that make up a hidden word. In the game I'm conceiving of, a five digit number between 10000 and 99999 would be generated. Let's say the number generated is 25529. The challenge is to use only the following operators to form a digit equation without altering the order of the digits:

+    addition

-    subtraction

x    multiplication

/    divide by

|    divide into

^    exponentiation

(     left bracket

)    right bracket

Figure 1 shows one possible representation:

Figure 1

The same digit equation would look mathematically as follows:$$ \Big ( 2 + \frac{5}{5} \Big )^2=9$$This is somewhat on the difficult side. Obviously an effective game nowadays involves a catchy user interface so coloured balls that pop up to start the game would be effective. The operators shown above would need to be able to be dragged and dropped between the digits in order to generate the equation. The successful creation of an equation would need to be displayed in mathematically readable way such as was done with the example of 25529.

The game could have different levels starting at the fairly elementary level. For example, 10348 could be rendered as:$$1+0+3+4=8$$This equation involves only the a single operation, addition, and the correct placement of the equal sign. By contrast, 25529 is considerably more challenging and involves the use of brackets, addition, division and exponentiation. Of course, for some numbers it is impossible to form an equation within the imposed constraints. An example is 27497 which is unsolvable as far as I can see. This is a long term project but something that I will keep thinking about or perhaps I'll discover that someone has already created such a game. Who knows?

For earlier posts on this theme see my posts titled The Number Plate Game from the 29th June 2024 and Forming Equations from the Digits of a Number on 14th March 2024. To generate some random five digits numbers follow this permalink.

Saturday, 3 August 2024

Probability of Reaching a Home Prime

Looking at the 51 steps required for 20240802 to reach a home prime (the subject of my previous post titled A Long Way Home), I fell to wondering about the probability of a composite number forming a prime when its prime factors are concatenated in ascending order, or any order for that matter. The key point is that the prime factors must all end in 1, 3, 7 or 9 and so the numbers that are formed from the concatenation must also end in these same digits. This is the first fact that we must bear in mind.

Another fact is that the likelihood that a randomly chosen number less than \(n\) is prime is (approximately) inversely proportional to the number of digits in \(n\) (source). If we look at the growth in the length of the concatenated numbers that arise from 20240802, we see that starting with eight digits we end up with a prime of 103 digits after 51 steps. This is very close to an increase of two digits per concatenation. As the concatenated numbers get larger, the likelihood of a prime arising decreases in proportion to the length of the number. Armed with these facts, we can set about finding for any starting number the average length of resulting home primes and the average number of steps required to reach them.

Let's start with eight digit composite numbers formed from the dates of the year such as 20,240,802 that arises from the 2nd August 2024. The probality of finding a prime with numbers of this length is 0.05944 but once we reach the home prime of 20240802 with its 103 digits this density has reduced to 0.00422. However, the numbers that are forming from the concatenation all end in 1, 3, 7 or 9 and this considerably boosts the probability of a prime being formed. The 60% of numbers ending in 0, 2, 4, 5, 6 or 8 simply cannot be formed from this type of concatenation. So instead of 0.05944 out of 1, we have 0.05944 out of 0.4 and instead of 0.00422 out of 1, we have 0.00422 out of 0.4 as well. This translates to about 0.1486 and 0.01055.


Matt Parker giving a nod to the taxicab number
in a YouTube video on concatenation: link

So starting with eight digit numbers we have about a 15% chance of forming a prime but by the time we reach 103 digit numbers that chance has plummeted to 1%. So every two digit increase in the length of a number decreases the probability of a prime forming by about 0.28%. Conversely, the chance of a prime NOT forming starts at 85% for an eight digit numbers and increases to 99% for 103 digit numbers. This is an increase of about 0.28% for every one of the approximately 50 steps in the concatenation process. So even though the chances of a prime NOT forming at each step in quite high and increasingly slowly, the chances of a prime NOT forming from successive concatenations quickly becomes quite low. The progression is as follows (rounding to two decimal places):

  • 0.85 to start with
  • 0.72 for the first concatenation
  • 0.53 for two concatenations
  • 0.28 for three concatenations
  • 0.08 for four concatenations
  • 0.01 for five concatenations
  • 0.00 for six concatenations and beyond
The mean is 0.05 so a prime should form between four and five concatenations on average. Clearly though there's more going on than is at first apparent here given that there are 471 numbers less than 10000 for which there are no known home primes with 49 being the first. It would seem likely that there will be many composite numbers without home primes amongst the numbers generated from the daily dates. 

Let's look at the some examples:
  • 20240801 --> 2 steps
  • 20240802 --> 51 steps
  • 20240803 --> 3 steps
  • 20240804 --> unknown
  • 20240805 --> 6 steps
  • 20240806 --> 1 step
  • 20240807 --> prime
  • 20240808 --> 8 steps
  • 20240809 --> 13 steps
  • 20240810 --> 11 steps
  • 20240811 --> 2 steps
  • 20240812 --> 13 steps
  • 20240813 --> 8 steps
  • 20240814 --> 14 steps
  • 20240815 --> unknown
  • 20240816 --> 25 steps
  • 20240817 --> 2 steps
  • 20240818 --> 5 steps
  • 20240819 --> prime
  • 20240820 --> 6 steps
If we ignore the primes, let the two unknowns be nominally 100 and put these results in ascending order, we get 1, 2, 2, 2, 3, 5, 6, 6, 8, 8, 11, 13, 13, 14, 25, 51, 100, 100 which has a median of 8. If we ignore the 51, 100, 100 then we have 1, 2, 2, 2, 3, 5, 6, 6, 8, 8, 11, 13, 13, 14, 25 which has median of 6. This is just a small sample and I'll need to research this topic further.

ADDENDUM

Concatenation of numbers can be achieved in Python and SageMath in two ways, one not involving strings (Method 1) and the other using strings (Method 2). I use the second method it's just simpler to remember. The code for both is as follows (permalink):

# Method 1
base=10
number1=17
number2=29
number=number1*10^(floor(log(floor(number2),base)+1))+number2
print(number)
# Method 2
number=int(str(number1)+str(number2))
print(number)

1729
1729

Friday, 2 August 2024

A Long Way Home

With large composite numbers, the path to a home prime can be a long one. This is certainly true of today's composite number 20240802 corresponding to today's date of 2nd August 2024.$$20240802=2 \times 3^2 \times 863 \times 1303$$I wondered why the algorithm running in my Jupiter Notebook was taking so long to calculate the home prime for today's number. It turns out that 51 steps are required before a home prime is reached. Here's the progression (toward the bottom of the list the larger numbers may run onto the next line):

20240802, 
2338631303, 
2953791951,
311233891689,
33741160974887,
311088424547577,
3347298836142697,
46728012558965891,
64269417270645951,
3713131313117863595291,
73131473868929224040761,
7157142964517218506685541,
37461590937100697383704241,
676775575541914812748937421,
33370837121353850660547143863,
103512102850518963266335968989,
127815055927956842230443590307,
3333334978717647771371995485881457,
35545734763423801200354273504161619,
3115096476834788845097622093725646027,
3171315807287116497834303893733982641037,
1938593133169178678118176191414687586788699,
7806127981924834247371605710953994219337521,
1113109500810161155118640365150812276512107483,
79263561175470733867058721787851202039247470829,
199350779397608484767800851518411783020176720951,
313893271587387422969396469847860991092333976542173,
19916894174850252716742066231437827881452587132198347,
333185411566209479042084941629363924712738008623074892523,
3223494969430572079429042941294041931241139987441774025309,
32950793229023376852456919797337294607377341857102318172479,
301958427353613415282754723578180598828447843204448262081363, 43671933129241050741953825012470051854111324175024183278643133, 3713710348596620298325276499784604740144926044521019175560918133, 43432033318665629558961303257652524300665434496179740124768638737, 438318191912142630256950384088336721700875079874885901277773615661, 33952660372710397050719260552116633226209979280798089039448973313459, 235473639043239560844701954001988841885040187355225129838688185185493, 333671045063366301288318623135523361878429909102403826971796025548984839, 7415772280289158642876806700567063245584286858045263726536419020786144949, 31915460753992647178331840969114638386529105925505411017314020817595444429481, 388215755079417212095611247626509474236722043804223179439175841269325900221647, 43119489467805082469367345227763064513316151461945387396217629252808742563363617, 7178040010219740423774713801327263673054482930504828408891656467662033385134241117, 109316473995628413986454085350966468455812414207316882972860619920620319817943453409, 2323834579133836345413046351762997943556241757630498282284882868364567485130261890219, 317300267606964982136843437711517492491619282822669294694863577107023014585554599905739, 52328463255749224374714279838161134823233769307043696613665389077650729417404884413292271, 3714392062034766290224112375598877216263278646829696160089485291757181880256559477546163399, 3394732071391164431104598827162026435326822795676460127579388576883851144072368157718797931641083, 19294447233994807147867590543139812872007673327880662223899101540689566880289506377715917567105333859
7772349034187438087121221820512743165100759812317447221713249182984386976343967857556366241938724210083

That final number is indeed prime while all the previous numbers back to our starting point of 20240802 are composite. Contrast this with yesterday's date number, 20240801, where:$$ 20240801=7 \times 2891543 $$The progression involves only two steps and is:$$20240801 \rightarrow 72891543 \rightarrow 3191278799$$The day before yesterday only six steps were needed for 20240731 to reach a home prime. 

I've written about home primes in earlier blog posts including Home Primes on 2nd May 2021. There are 471 numbers less than 10000 for which there are no known home primes with 49 being the first. It would seem likely that there are many composite numbers without home primes amongst the numbers generated from the daily dates.