Tuesday, 24 March 2026

Digit Manipulation


Video created by NotebookLM based on blog content

DIGITS TO SQUARES

Yesterday I turned 28113 days old and this number is a member of OEIS A048383: numbers \(k\) such that replacing each nonzero digit \(d\) with the \(d\)-th prime (replacing each 0 digit with a 1) yields a square. So this means that:$$28113 \rightarrow 319225 = 5^2 \times 113^2$$The members of this sequence are few and far between and in the range up to 40000 only the following numbers satisfy (permalink):$$ \begin{align} 0 &\rightarrow 1 = 1\\13 &\rightarrow 25 = 5^2\\113 &\rightarrow 225 = 3^2 \times 5^2\\2410 &\rightarrow 3721 = 61^2\\4113 &\rightarrow 7225 = 5^2 \times 17^2\\6113 &\rightarrow 13225 = 5^2 \times 23^2\\8210 &\rightarrow 19321 = 139^2\\14113 &\rightarrow 27225 = 3^2 \times 5^2 \times 11^2\\23410 &\rightarrow 35721 = 3^6 \times 7^2\\28113 &\rightarrow 319225 = 5^2 \times 113^2\\33113 &\rightarrow 55225 = 5^2 \times 47^2\\34010 &\rightarrow 57121 = 239^2\\35113 &\rightarrow 511225 = 5^2 \times 11^2 \times 13^2\\\end{align}$$DIGITS TO PRIMES

A variation on this theme is OEIS A048381:


A048381: numbers \(k\) such that replacing each nonzero digit \(d\) with the \(d\)-th prime (replacing each 0 digit with a 1) yields a prime.

Members of this sequence are far more numerous with 5629 in the range up to 40000. An example is 28112 since:$$28112 \rightarrow 319223 \text{ which is prime} $$Some upcoming members are:

28124, 28146, 28152, 28155, 28202, 28210, 28214, 28216, 28226, 28228, 28230, 28234, 28235, 28236, 28247, 28265, 28270, 28277, 28289, 28294, 28295, 28298, 28300, 28317, 28319, 28328, 28329, 28344, 28359, 28360, 28368, 28388, 28392, 28397, 28414, 28418, 28422, 28429, 28434, 28449, 28458, 28464, 28470, 28474, 28485, 28490, 28498, 28502, 28504, 28515, 28524, 28525, 28529, 28546, 28562, 28575, 28592, 28599, 28606, 28612, 28614, 28622, 28630, 28652, 28658, 28665, 28667, 28674, 28684, 28686, 28706, 28717, 28724, 28744, 28752, 28772, 28786, 28807, 28810, 28814, 28825, 28827, 28838, 28854, 28868, 28870, 28876, 28886, 28888, 28890, 28928, 28929, 28932, 28948, 28955, 28960, 28966, 28979, 28984, 28988, 28995, 28997

One way to thin the numbers when there are so many in a given range is to require that the numbers come in pairs that are consecutive integers. If this requirement is imposed then the 5629 reduces to 580. Imposing the restriction that the numbers are triplets that are consecutive integers reduces the 580 further to a manageable 103:

1, 2, 3, 4, 5, 6, 7, 24, 25, 144, 166, 167, 414, 474, 506, 674, 897, 898, 1026, 1027, 1176, 1177, 1398, 1516, 1824, 2035, 2074, 2094, 2146, 2544, 3316, 4044, 5247, 5248, 5286, 5514, 6044, 6484, 7116, 7117, 7118, 7264, 7918, 8008, 8127, 8444, 8665, 10016, 11046, 11047, 11404, 13068, 13445, 14224, 14584, 15886, 16055, 16346, 16347, 16505, 16945, 18306, 18497, 19276, 19465, 20044, 20124, 21797, 21798, 22167, 22416, 22417, 22586, 22694, 22767, 23336, 23774, 24726, 24727, 24845, 25934, 26608, 26844, 26885, 28234, 29376, 29377, 29714, 29715, 29917, 30145, 30705, 32244, 32248, 33807, 35405, 35647, 36018, 36635, 37888, 38097, 39067, 39527

Let's take 28234 as an example where:$$ \begin{align} 28234 &\rightarrow 319357\\28235 &\rightarrow 3193511\\28236 &\rightarrow 3193513 \end{align}$$There is of course an initial run of seven numbers (1 to 7) and after that there are runs of four numbers beginning with:

24, 166, 897, 1026, 1176, 5247, 7116, 7117, 11046, 16346, 21797, 22416, 24726, 29376, 29714

Finally there is only one run of five numbers and it starts with 7116.

DIGITS TO PALINDROMES

Another variation, using this same method of digit manipulation, is to ask what non-palindromic number become palindromes. Well, in the range up to 40000, it turns out that 333 numbers satisfy this condition (permalink). The numbers from 28113 onwards are:

28086, 28586, 28686, 28786, 28802, 28886, 29029, 29069, 29129, 29199, 29212, 29229, 29329, 29429, 29529, 29569, 29612, 29669, 29769, 29869, 29912, 29999, 30053, 30553, 30653, 30753, 30853, 32063, 32193, 32563, 32663, 32763, 32863, 32993, 34073, 34573, 34673, 34773, 34873, 35003, 35503, 36203, 36603, 36903, 37403, 37703, 38803, 39213, 39613, 39913

Let's use 28086 as an example:$$28086 \rightarrow 31911913$$Clearly there are many possible variations using just this particular type of digit manipulation and in this post I've shown examples of three of them where the digits \(d\) are manipulated as follows:$$ \begin{align} d &\rightarrow \text{ prime}(d) \text{ if } d \neq 0 \\0 &\rightarrow 1 \end{align} $$However, other manipulations are limited only by your imagination. An example of different type of manipulation would be:$$ d \rightarrow d^{ \, \small{2}}$$We can ask how many non-palindromic numbers become palindromes when their digits are manipulated in this manner (squared). In the range up to 40000, the answer is that there are 96 suitable numbers and they are (permalink):

19, 28, 37, 41, 72, 199, 288, 327, 377, 441, 461, 732, 772, 1191, 1281, 1371, 1411, 1721, 1919, 1999, 2192, 2282, 2372, 2412, 2722, 2828, 2888, 3193, 3207, 3217, 3227, 3237, 3283, 3373, 3413, 3723, 3737, 3777, 4141, 4441, 4661, 7032, 7132, 7232, 7272, 7332, 7772, 11991, 12881, 13271, 13771, 14411, 14611, 17321, 17721, 19019, 19119, 19219, 19319, 19999, 21992, 22882, 23272, 23772, 24412, 24612, 27322, 27722, 28028, 28128, 28228, 28328, 28888, 31993, 32007, 32117, 32197, 32227, 32287, 32337, 32377, 32417, 32727, 32883, 33273, 33773, 34413, 34613, 37037, 37137, 37237, 37277, 37323, 37337, 37723, 37777

An example is 28028 where$$28028 \rightarrow 4640464$$

Saturday, 21 March 2026

Concatenating Reversible Sphenic Numbers

My previous post Concatenating Emirpimes suggested the concatenation of reversible sphenic numbers as a logical sequel. A sphenic number that is still sphenic when its digits are reversed is sometimes called a \( \textbf{cinephs} \). Let's take 418 as an example of the type of number that we want to identify:$$ \begin{align} 418 &= 2 \times 11 \times 19 \\ 814 &= 2 \times 11 \times 37 \\ 418814 &= 2 \times 11 \times 19037 \end{align}$$There are, coincidentally, 418 such numbers in the range up to 40000. Here are the details (permalink):

=== Cineph Concatenation Statistics ===

Range evaluated: 1 to 40000

1. Sphenic numbers: 7720 (19.30% of the range)

2. Cinephs: 1890 (4.72% of the range)

3. Successful Cinephs: 418 (1.0450% of the range)

=== Comma-Separated List of Successful Cinephs ===

418, 682, 759, 814, 957, 1034, 1095, 1113, 1185, 1342, 1419, 1446, 1606, 1614, 1902, 1965, 2014, 2035, 2282, 2414, 2431, 2438, 2494, 2635, 2665, 2686, 3018, 3059, 3138, 3201, 3278, 3297, 3358, 3495, 3597, 3606, 3678, 3685, 3714, 3729, 3765, 3926, 4301, 4382, 4543, 4565, 4715, 4945, 5174, 5362, 5495, 5863, 5986, 6035, 6061, 6083, 6206, 6293, 6806, 7185, 7305, 7414, 7449, 7567, 7645, 7657, 7662, 7718, 8155, 8174, 8378, 8386, 8390, 8393, 8555, 8734, 8786, 8789, 8987, 9138, 9141, 9213, 9309, 9321, 9354, 9362, 9503, 9515, 9519, 9807, 9822, 9885, 9951, 9978, 10095, 10246, 10263, 10274, 10326, 10382, 10490, 10502, 10509, 10554, 10635, 10761, 10835, 10879, 10915, 11098, 11342, 11395, 11398, 11407, 11577, 11605, 11753, 11922, 11937, 11958, 11982, 12174, 12218, 12257, 12378, 12498, 12529, 12551, 12595, 12859, 12874, 12890, 12914, 13137, 13143, 13222, 13305, 13514, 13574, 13618, 13634, 13783, 13786, 13906, 14035, 14043, 14055, 14127, 14174, 14223, 14298, 14313, 14443, 14573, 14590, 14619, 14646, 14655, 14846, 14889, 14894, 14955, 15235, 15323, 15422, 15430, 15521, 15585, 15626, 15657, 15794, 15818, 15914, 15958, 15994, 16098, 16159, 16518, 16558, 16666, 16701, 16914, 16915, 16946, 17006, 17139, 17353, 17445, 17518, 17534, 17799, 17805, 17814, 17818, 17978, 18093, 18123, 18147, 18205, 18222, 18231, 18309, 18395, 18458, 18555, 18579, 18685, 18717, 18814, 18854, 19023, 19178, 19221, 19317, 19382, 19545, 19605, 19623, 19877, 19923, 19947, 19987, 20009, 20066, 20195, 20270, 20305, 20315, 20530, 20594, 20657, 20726, 20758, 20870, 20905, 20945, 20965, 20966, 22058, 22282, 22562, 22582, 22591, 22645, 22933, 22939, 22945, 22970, 24002, 24026, 24095, 24265, 24409, 24479, 24583, 24590, 24739, 24817, 24878, 24962, 24973, 26090, 26102, 26134, 26146, 26245, 26266, 26273, 26429, 26494, 26506, 26546, 26555, 26614, 26638, 26663, 26758, 26873, 26878, 26930, 26939, 26990, 28085, 28165, 28186, 28222, 28237, 28358, 28418, 28426, 28441, 28483, 28514, 28645, 28747, 28835, 28870, 28918, 30054, 30099, 30126, 30277, 30418, 30502, 30651, 30795, 30943, 31026, 31027, 31035, 31191, 31254, 31386, 31658, 31719, 31978, 32039, 32043, 32181, 32295, 32351, 32417, 32442, 32613, 32846, 32857, 32898, 32907, 32938, 33143, 33162, 33186, 33378, 33429, 33473, 33555, 33583, 33585, 33754, 33818, 33835, 33906, 33918, 33922, 34005, 34077, 34078, 34131, 34133, 34158, 34203, 34222, 34257, 34474, 34562, 34563, 34661, 34705, 34826, 35006, 35094, 35123, 35202, 35274, 35319, 35382, 35618, 35619, 35871, 35949, 35985, 36003, 36039, 36165, 36174, 36226, 36355, 36474, 36586, 36606, 36627, 36935, 36958, 37317, 37329, 37367, 37411, 37418, 37433, 37527, 37614, 37634, 37743, 37754, 37970, 38049, 38085, 38193, 38294, 38399, 38451, 38467, 38533, 38555, 38643, 39081, 39169, 39305, 39306, 39351, 39358, 39399, 39458, 39562, 39785, 39842, 39918, 39966

As we learned in my previous post: 
There is a fundamental rule in number theory: Every palindrome with an even number of digits is divisible by 11.

Thus all the above numbers have 11 as a prime factor. Let's take 39358 as another example: $$ \begin{align} 39358 &= 2 \times 11 \times 1789 \\ 85393 &= 7 \times 11 \times 1109 \\ 3935885393 &= 11 \times 397 \times 901279\end{align}$$Of course, if we were to try this technique on emirps (reversible primes), we would never end up with a prime because the resultant number would always be divisible by 11. For example, 37 and 73 combine to form$$ 3773 = 11 \times 343 =11 \times 7^3$$

Friday, 20 March 2026

Concatenating Emirpimes

Emirpimes have the property that they remain semiprimes when reversed. Thus 15 = 3 x 5 becomes 51 when the digits are reversed and 51 = 3 x 17 which is also a semiprime. What happens to the emirpimes if it is concatenated with its reverse. Does it remain a semiprime? In the case 15, this leads to 1551 = 3 x 11 x 47 which is a sphenic number and not a semiprime. The first such emirpimes is 94 because 9449 = 11 x 859 is a semiprime. In fact all such emirpimes will have 11 as a factor. Here is Gemini's explanation:

The reason no numbers starting with the digit 2 appear in your output comes down to two absolute mathematical rules regarding divisibility: the behavior of even-length palindromes and the properties of even numbers.

When you concatenate a number that begins with 2 with its exact reverse, you are guaranteeing that the resulting number will have at least three prime factors, which automatically disqualifies it from being a semiprime.

Here is the step-by-step breakdown of exactly why this happens:

1. The Concatenated Number is Always an Even-Length Palindrome

When you take any number string and append its exact reverse (e.g., $n = 26$, $rev = 62$, resulting in 2662), you create a perfect mirror image. Because you are doubling the number of digits, the resulting palindrome will always have an even length.

There is a fundamental rule in number theory: Every palindrome with an even number of digits is divisible by 11. Because your program only evaluates these concatenated mirror-images, every single number evaluated in that final step has 11 as one of its prime factors.

2. The Resulting Number Always Ends in 2

If your original number ($n$) starts with the digit 2, its reverse will naturally end with the digit 2. When you concatenate the original number with its reverse, the very last digit of the new string will be the last digit of the reverse.

For example:

  • Original: 215

  • Reverse: 512

  • Concatenation: 215512

Because the concatenated number ends in 2, it is an even number. This means 2 is definitively another prime factor of the concatenated number.

3. The Factor Count Exceeds the Semiprime Limit

By definition, a semiprime must have exactly two prime factors (e.g., $p_1 \times p_2$).

If you start with a number beginning with 2, we have already established that the final concatenated number is divisible by both 11 and 2. Therefore, the number is a multiple of 22.

For a multiple of 22 to be a semiprime, the number would have to be exactly 22 itself (where 2 and 11 are the only factors). For your program to generate 22, the original number would have to be 2, and the reverse would have to be 2. This fails on multiple fronts:

  • 2 is a prime number, not a semiprime.

  • Your code explicitly filters out palindromes (n != rev_n), so it would ignore 2 anyway.

Any valid concatenated number your program produces that begins with a 2 will be much larger than 22 (the smallest would be 2442, derived from $n=24$). Therefore, its prime factorization will always look like $2 \times 11 \times x$, containing at least three prime factors.

Broader Implications

Because of these exact same mathematical rules, your output will also never contain numbers starting with:

  • 4, 6, or 8: The resulting concatenations would all end in an even number, meaning they are divisible by 2 and 11, resulting in too many factors.

  • 5: The resulting concatenation would end in a 5, meaning it is divisible by 5 and 11, again resulting in too many factors.

The only numbers that can mathematically survive this final semiprime check are those starting with 1, 3, 7, or 9.

Here is the list of emirpimes that satisfy in the range up to 40,000 (permalink):

=== Emirpime Concatenation Statistics ===

Range evaluated: 1 to 40000

1. Semiprimes: 9790 (24.47% of the range)

2. Emirpimes: 3450 (8.62% of the range)

3. Successful Emirpimes: 476 (1.19% of the range)

94, 115, 169, 185, 341, 355, 394, 398, 766, 794, 923, 926, 955, 985, 1027, 1046, 1141, 1174, 1195, 1202, 1238, 1247, 1306, 1343, 1366, 1382, 1417, 1418, 1466, 1642, 1658, 1703, 1714, 1754, 1757, 1769, 1843, 1891, 1915, 1927, 1985, 3047, 3062, 3071, 3091, 3097, 3098, 3103, 3151, 3166, 3227, 3317, 3385, 3403, 3473, 3599, 3635, 3646, 3653, 3785, 3817, 3866, 3949, 3959, 3979, 3983, 7051, 7058, 7082, 7094, 7165, 7169, 7183, 7186, 7223, 7226, 7235, 7274, 7291, 7318, 7346, 7354, 7367, 7403, 7522, 7637, 7655, 7663, 7715, 7754, 7795, 7849, 7855, 7981, 9121, 9242, 9259, 9346, 9427, 9569, 9578, 9593, 9599, 9617, 9727, 9755, 9809, 9946, 9953, 9983, 9997, 10033, 10085, 10129, 10195, 10261, 10342, 10345, 10462, 10466, 10483, 10517, 10541, 10546, 10558, 10637, 10673, 10705, 10805, 11006, 11141, 11147, 11249, 11302, 11306, 11363, 11366, 11539, 11563, 11591, 11641, 11651, 11653, 11654, 11714, 11723, 11851, 11893, 11917, 11945, 12001, 12013, 12067, 12127, 12146, 12199, 12202, 12217, 12283, 12317, 12361, 12367, 12439, 12458, 12494, 12509, 12674, 12718, 12751, 12758, 12761, 12851, 12877, 12913, 12937, 13102, 13106, 13133, 13142, 13193, 13273, 13322, 13373, 13391, 13459, 13529, 13637, 13739, 13742, 13787, 13817, 13934, 13993, 14015, 14111, 14171, 14213, 14219, 14242, 14261, 14273, 14291, 14318, 14359, 14486, 14501, 14611, 14642, 14647, 14765, 14786, 14834, 14999, 15094, 15157, 15335, 15362, 15389, 15403, 15623, 15658, 15779, 15781, 15793, 15815, 15863, 15874, 15893, 15989, 16003, 16123, 16129, 16153, 16207, 16265, 16331, 16334, 16367, 16387, 16489, 16507, 16859, 16865, 16909, 16969, 17083, 17218, 17261, 17305, 17311, 17441, 17503, 17533, 17611, 17614, 17662, 17687, 18035, 18155, 18463, 18482, 18547, 18613, 18623, 18686, 18689, 18695, 18794, 18806, 18847, 18937, 19015, 19165, 19217, 19246, 19286, 19297, 19331, 19337, 19354, 19358, 19405, 19445, 19579, 19585, 19607, 19637, 19667, 19757, 19858, 19882, 19931, 19969, 30043, 30143, 30182, 30407, 30413, 30437, 30574, 30605, 30607, 30641, 30662, 30731, 30754, 30755, 30779, 30826, 30854, 30865, 30886, 30913, 30991, 30994, 30995, 31127, 31138, 31282, 31342, 31399, 31453, 31807, 31843, 31853, 31946, 31969, 32066, 32071, 32137, 32138, 32177, 32366, 32455, 32458, 32501, 32593, 32602, 32663, 32666, 32765, 32842, 32845, 32891, 33109, 33253, 33257, 33445, 33458, 33559, 33593, 33737, 33991, 34073, 34154, 34169, 34186, 34187, 34205, 34379, 34382, 34409, 34477, 34571, 34598, 34657, 34723, 34745, 34802, 34831, 34907, 34999, 35078, 35135, 35137, 35147, 35173, 35215, 35263, 35269, 35285, 35471, 35522, 35545, 35567, 35723, 35773, 35779, 35813, 35881, 36029, 36035, 36065, 36139, 36143, 36203, 36227, 36311, 36422, 36427, 36446, 36481, 36503, 36535, 36614, 36626, 36631, 36649, 36679, 36733, 36734, 36745, 36794, 36802, 37006, 37031, 37034, 37099, 37153, 37157, 37231, 37331, 37358, 37399, 37438, 37457, 37477, 37487, 37498, 37514, 37574, 37601, 37739, 37834, 37837, 37931, 37946, 37958, 38174, 38209, 38245, 38401, 38413, 38414, 38477, 38497, 38534, 38585, 38597, 38635, 38719, 38785, 38806, 38951, 39037, 39127, 39142, 39205, 39253, 39265, 39289, 39449, 39518, 39523, 39653, 39797, 39826, 39871, 39898, 39899, 39911, 39931, 39947, 39958, 39959, 39977