Monday, 16 June 2025

A Special 29x + 1 Map

 In blog posts titled:

I've looked at Collatz-style sequences of the form px+1 that map a number n to the following:
  • nn2 if 2|n
  • nn3 if 3|n
  • nn5 if 5|n
     
  • nnp1 if (p1)|n
  • np×n+1  if none of the primes less than p divide n
Other mappings are of course possible and the following is perhaps the simplest of all. For a given prime p when applied to a number n, the rule is:
  • nn2 if n is even
  • np×n+1 if n is odd
For p=3, this is the Collatz trajectory of the number. Let's apply this sort of modified px+1 mapping in the case of n=3. The sequence formed by the trajectory up to one million is then (permalink):

3, 88, 44, 22, 11, 320, 160, 80, 40, 20, 10, 5, 146, 73, 2118, 1059, 30712, 15356, 7678, 3839, 111332, 55666, 27833, 807158, 403579, 11703792, 5851896, 2925948, 1462974, 731487 (OEIS A037112)

The trajectory is shown in Figure 1 using a logarithmic scale for the y axis:


Figure 1: permalink

By contrast if the first mentioned rule above were applied then the trajectory would be short-lived indeed:31301551It can be seen that the trajectory very quickly enters a loop. 

Letting p=101 and applying the mapping to n=3 once again, we get the following sequence up to one million formed by the trajectory (permalink):

3, 304, 152, 76, 38, 19, 1920, 960, 480, 240, 120, 60, 30, 15, 1516, 758, 379, 38280, 19140, 9570, 4785, 483286, 241643

The trajectory is shown in Figure 2 using a logarithmic scale for the y axis:

Figure 2: permalink

Thursday, 12 June 2025

Fibonacci Numbers Derived From Single Digits

Quite some time ago now I used "reverse engineering" to find the seed numbers leading to a given number. For example, take the number 28047. Using this algorithm (permalink), I obtain the following output.

Seed numbers for Fibonacci sequence are 3 and 9

[3, 9, 12, 21, 33, 54, 87, 141, 228, 369, 597, 966, 1563, 2529, 4092, 6621, 10713, 17334, 28047]

I outlined the construction of this algorithm in a post titled Finding Fibonacci and Tribonacci Seed Numbers in July of 2019. The previously applied algorithm relies on the fact that in a Fibonacci sequence the ratio of progressive terms approximates the golden ratio. Let's apply the algorithm once again but this time to the number 28048. The following output is obtained:

Seed numbers for Fibonacci sequence are 32 and 175

[32, 175, 207, 382, 589, 971, 1560, 2531, 4091, 6622, 10713, 17335, 28048]

The difference this time is that the seed numbers are no longer single digits and this is generally the case. What I wanted to know was what numbers in the range up to 40000 can be formed using single digits as seed numbers after applying the Fibonacci algorithm to generate the subsequent numbers. It turns out that there are only 387 such numbers in the range from 10 to 40000. They are (permalink):

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, 60, 61, 63, 64, 65, 66, 68, 69, 71, 72, 73, 74, 76, 77, 78, 79, 81, 82, 84, 86, 87, 89, 91, 92, 94, 97, 99, 102, 104, 105, 107, 110, 112, 115, 117, 118, 120, 123, 125, 126, 128, 131, 133, 136, 139, 141, 144, 147, 149, 152, 157, 160, 165, 168, 170, 173, 178, 181, 186, 189, 191, 194, 199, 202, 204, 207, 212, 215, 220, 225, 228, 233, 238, 241, 246, 254, 259, 267, 272, 275, 280, 288, 293, 301, 306, 309, 314, 322, 327, 330, 335, 343, 348, 356, 364, 369, 377, 385, 390, 398, 411, 419, 432, 440, 445, 453, 466, 474, 487, 495, 500, 508, 521, 529, 534, 542, 555, 563, 576, 589, 597, 610, 623, 631, 644, 665, 678, 699, 712, 720, 733, 754, 767, 788, 801, 809, 822, 843, 856, 864, 877, 898, 911, 932, 953, 966, 987, 1008, 1021, 1042, 1076, 1097, 1131, 1152, 1165, 1186, 1220, 1241, 1275, 1296, 1309, 1330, 1364, 1385, 1398, 1419, 1453, 1474, 1508, 1542, 1563, 1597, 1631, 1652, 1686, 1741, 1775, 1830, 1864, 1885, 1919, 1974, 2008, 2063, 2097, 2118, 2152, 2207, 2241, 2262, 2296, 2351, 2385, 2440, 2495, 2529, 2584, 2639, 2673, 2728, 2817, 2872, 2961, 3016, 3050, 3105, 3194, 3249, 3338, 3393, 3427, 3482, 3571, 3626, 3660, 3715, 3804, 3859, 3948, 4037, 4092, 4181, 4270, 4325, 4414, 4558, 4647, 4791, 4880, 4935, 5024, 5168, 5257, 5401, 5490, 5545, 5634, 5778, 5867, 5922, 6011, 6155, 6244, 6388, 6532, 6621, 6765, 6909, 6998, 7142, 7375, 7519, 7752, 7896, 7985, 8129, 8362, 8506, 8739, 8883, 8972, 9116, 9349, 9493, 9582, 9726, 9959, 10103, 10336, 10569, 10713, 10946, 11179, 11323, 11556, 11933, 12166, 12543, 12776, 12920, 13153, 13530, 13763, 14140, 14373, 14517, 14750, 15127, 15360, 15504, 15737, 16114, 16347, 16724, 17101, 17334, 17711, 18088, 18321, 18698, 19308, 19685, 20295, 20672, 20905, 21282, 21892, 22269, 22879, 23256, 23489, 23866, 24476, 24853, 25086, 25463, 26073, 26450, 27060, 27670, 28047, 28657, 29267, 29644, 30254, 31241, 31851, 32838, 33448, 33825, 34435, 35422, 36032, 37019, 37629, 38006, 38616, 39603

The algorithm can also be used to enter any of the above numbers to find the seed numbers and the resulting sequence. For example, entering the last number in the above sequence (39603) reveals that it can formed by three different pairs of seed numbers: (1, 3), (3, 4) and (4, 7). The resulting sequences are essentially the same from 11 onwards:

1, 3, 4, 7, 11, 18, 29, 47, 76, 123, 199, 322, 521, 843, 1364, 2207, 3571, 5778, 9349, 15127, 24476, 39603

3, 4, 7, 11, 18, 29, 47, 76, 123, 199, 322, 521, 843, 1364, 2207, 3571, 5778, 9349, 15127, 24476, 39603

4, 7, 11, 18, 29, 47, 76, 123, 199, 322, 521, 843, 1364, 2207, 3571, 5778, 9349, 15127, 24476, 39603

Between 10 and 100, the numbers that CANNOT be derived from single digit seed numbers are 59, 62, 67, 70, 75, 80, 83, 85, 88, 90, 93, 95, 96, 98 and 100. The frequency of these numbers increases rapidly as the numbers get larger. For example, between 38616 and 39603 there is a gap of 87 and so there are 85 such numbers in the range.

Monday, 9 June 2025

Nothing New Under The Sun

Every day I try to form a digit equation from the digits of the number associated with my diurnal age. Today's number was 27826. Usually I succeed but sometimes I don't. I've described the rules in my blog post titled Forming Digit Equations: A Game. Applying these rules to 27826 we get (with | representing divided into):2+7=82|65=83=5Looking at this number however, something else caught my eye and it involved powers of 2. I thought: suppose that instead of 27 there was 27=128 and instead of 26 there was 26=64. In that case the number would be 128864. Now we have a number that is a concatenation of powers of 2 because (with | this time representing concatenation) we have:128864=27|23|26I wondered how many numbers in the range up to 40000 have the property that they are a concatenation of powers of 2, which includes 20=1. As is my lazy way nowadays I put Gemini to work writing the Python code (permalink) to find all the numbers in this range. It turns out that there are 1563 such numbers with the largest being 32888 where:32888=25|23|23|23The initial numbers are 1, 2, 4, 8, 11, 12, 14, 16, 18, 21 and so I thought I'd put these numbers into the OEIS and see if anything turned up. To my surprise, the sequence is listed (A381259). See Figure 1.

Figure 1: link

Hence the title of this post "Nothing New Under the Sun" because clearly someone had thought of such a sequence before I had. I won't list all the numbers in the range up to 40000 but here are the ones that are coming up for me:

28111, 28112, 28114, 28116, 28118, 28121, 28122, 28124, 28128, 28132, 28141, 28142, 28144, 28148, 28161, 28162, 28164, 28168, 28181, 28182, 28184, 28188, 28192, 28211, 28212, 28214, 28216, 28218, 28221, 28222, 28224, 28228, 28232, 28241, 28242, 28244, 28248, 28256, 28264, 28281, 28282, 28284, 28288, 28321, 28322, 28324, 28328, 28411, 28412, 28414, 28416, 28418, 28421, 28422, 28424, 28428, 28432, 28441, 28442, 28444, 28448, 28464, 28481, 28482, 28484, 28488, 28512, 28641, 28642, 28644, 28648, 28811, 28812, 28814, 28816, 28818, 28821, 28822, 28824, 28828, 28832, 28841, 28842, 28844, 28848, 28864, 28881, 28882, 28884, 28888, 32111, 32112, 32114, 32116, 32118, 32121, 32122, 32124, 32128, 32132, 32141, 32142, 32144, 32148, 32161, 32162, 32164, 32168, 32181, 32182, 32184, 32188, 32211, 32212, 32214, 32216, 32218, 32221, 32222, 32224, 32228, 32232, 32241, 32242, 32244, 32248, 32256, 32264, 32281, 32282, 32284, 32288, 32321, 32322, 32324, 32328, 32411, 32412, 32414, 32416, 32418, 32421, 32422, 32424, 32428, 32432, 32441, 32442, 32444, 32448, 32464, 32481, 32482, 32484, 32488, 32512, 32641, 32642, 32644, 32648, 32768, 32811, 32812, 32814, 32816, 32818, 32821, 32822, 32824, 32828, 32832, 32841, 32842, 32844, 32848, 32864, 32881, 32882, 32884, 32888

I looked long and hard at 32768 in the list above because I couldn't see how it could be a concatenation of powers of 2. I had to ask Gemini to clarify. It did:32768=215So there you have it. I thought I'd discovered a brand new sequence but it was already in the OEIS database but it hadn't been there for long as the date of inclusion is February 18th 2025.

Now the Python code is easily modified to deal with the powers of other numbers. Let's consider powers of 3. There are 570 numbers satisfying this criterion in the range up to 40000 (permalink). Here are the ones that are coming up for me (some of which I'll see hopefully):

27911, 27913, 27919, 27927, 27931, 27933, 27939, 27981, 27991, 27993, 27999, 31111, 31113, 31119, 31127, 31131, 31133, 31139, 31181, 31191, 31193, 31199, 31243, 31271, 31273, 31279, 31311, 31313, 31319, 31327, 31331, 31333, 31339, 31381, 31391, 31393, 31399, 31729, 31811, 31813, 31819, 31911, 31913, 31919, 31927, 31931, 31933, 31939, 31981, 31991, 31993, 31999, 32187, 32431, 32433, 32439, 32711, 32713, 32719, 32727, 32731, 32733, 32739, 32781, 32791, 32793, 32799, 33111, 33113, 33119, 33127, 33131, 33133, 33139, 33181, 33191, 33193, 33199, 33243, 33271, 33273, 33279, 33311, 33313, 33319, 33327, 33331, 33333, 33339, 33381, 33391, 33393, 33399, 33729, 33811, 33813, 33819, 33911, 33913, 33919, 33927, 33931, 33933, 33939, 33981, 33991, 33993, 33999, 36561, 37291, 37293, 37299, 38111, 38113, 38119, 38127, 38131, 38133, 38139, 38181, 38191, 38193, 38199, 39111, 39113, 39119, 39127, 39131, 39133, 39139, 39181, 39191, 39193, 39199, 39243, 39271, 39273, 39279, 39311, 39313, 39319, 39327, 39331, 39333, 39339, 39381, 39391, 39393, 39399, 39729, 39811, 39813, 39819, 39911, 39913, 39919, 39927, 39931, 39933, 39939, 39981, 39991, 39993, 39999

Let's take the first number in the list above:27911=33|32|30|30Similarly with powers of 5 where we have 103 suitable numbers in the range up to 40000 (permalink). We can list them here as there aren't that many.

1, 5, 11, 15, 25, 51, 55, 111, 115, 125, 151, 155, 251, 255, 511, 515, 525, 551, 555, 625, 1111, 1115, 1125, 1151, 1155, 1251, 1255, 1511, 1515, 1525, 1551, 1555, 1625, 2511, 2515, 2525, 2551, 2555, 3125, 5111, 5115, 5125, 5151, 5155, 5251, 5255, 5511, 5515, 5525, 5551, 5555, 5625, 6251, 6255, 11111, 11115, 11125, 11151, 11155, 11251, 11255, 11511, 11515, 11525, 11551, 11555, 11625, 12511, 12515, 12525, 12551, 12555, 13125, 15111, 15115, 15125, 15151, 15155, 15251, 15255, 15511, 15515, 15525, 15551, 15555, 15625, 16251, 16255, 25111, 25115, 25125, 25151, 25155, 25251, 25255, 25511, 25515, 25525, 25551, 25555, 25625, 31251, 31255

Let's take the last number in the list:31255=55|51Representations are not necessarily unique. For example:15125=50|51|53=50|51|50|52Finally let's consider powers of 7 where there are 96 in the range up to 40000 (permalink). They are:

1, 7, 11, 17, 49, 71, 77, 111, 117, 149, 171, 177, 343, 491, 497, 711, 717, 749, 771, 777, 1111, 1117, 1149, 1171, 1177, 1343, 1491, 1497, 1711, 1717, 1749, 1771, 1777, 2401, 3431, 3437, 4911, 4917, 4949, 4971, 4977, 7111, 7117, 7149, 7171, 7177, 7343, 7491, 7497, 7711, 7717, 7749, 7771, 7777, 11111, 11117, 11149, 11171, 11177, 11343, 11491, 11497, 11711, 11717, 11749, 11771, 11777, 12401, 13431, 13437, 14911, 14917, 14949, 14971, 14977, 16807, 17111, 17117, 17149, 17171, 17177, 17343, 17491, 17497, 17711, 17717, 17749, 17771, 17777, 24011, 24017, 34311, 34317, 34349, 34371, 34377

Let's take the last number in the list again:34377=73|71|71Apart from the powers of 2, none of the sequences above are listed in the OEIS. Of course, those numbers containing only the digit 1 are common to all the sequences.

Saturday, 7 June 2025

Dangers of Differentiation

The following shows an interesting line of reasoning posed by Math Lazy Hazel on Twitter.



What is faulty in this demonstration that 2 = 1? I asked Gemini via this prompt:
There is a flaw in the logic of the Mathematics on this uploaded file. Can you ascertain what it is? On the surface the differentiation seems logical enough.

The response was quite well explained.

Of course. The flaw in the mathematical logic lies in the incorrect application of differentiation to a sum with a variable number of terms. Here’s a breakdown of the error: 
The Flaw Explained 
The core mistake happens when moving from the second to the third line of the "proof." 
The Setup
The proof starts by defining x2 as the sum of x added to itself x times: x2=x+x++xx times This definition itself is only truly valid for integer values of x. 2.

The Incorrect Differentiation
The next step applies the derivative with respect to x to both sides: ddxx2=ddx(x+x++xx times) The left side correctly becomes 2x. However, the right side is differentiated incorrectly. The proof mistakenly treats the number of terms in the sum as a constant. The rule for the derivative of a sum, ddxfi=ddxfi, only works when the number of terms is constant. In this case, the number of terms is x, the very variable you are differentiating with respect to. You cannot simply differentiate each term individually and add them up while ignoring that the number of terms is also changing.

Correct Approach
To correctly differentiate the expression on the right, you must use the product rule, because it's effectively a product of two functions of x: the value of each term (x) and the number of terms (x). Let the function be f(x)=xx. Using the product rule (uv)=uv+uv: ddx(xx)=(ddxx)x+x(ddxx)=(1x)+(x1)=x+x=2x This correct differentiation results in 2x=2x, which is a valid identity and does not lead to the false conclusion that 2=1. In short, the proof is flawed because it misapplies the rules of differentiation by treating a variable number of terms as a constant.

Rara Avis

The number associated with my diurnal age today, 27824, is what could be termed a rara avis (someone or something that is rare) because, in the range up to 40,000, there are only three other numbers with which it sharts a certain property. The property is that: 

the sum of their proper divisors minus
the product of their digits equals the number


The numbers are 198, 4172, 7144 and 27824 and they are the initial members of OEIS A331098. Figure 1 shows the details:


Figure 1: permalink

Here is a longer list of the sequence's members:

198, 4172, 7144, 27824, 72212, 111126, 1111134, 1113114, 1131114, 7121212, 11131122, 13111122, 33550336, 111711124, 1111113114, 1111212172, 1113111114, 2111211172, 7111211212, 8589869056, 11112117212, 11113111122, 11121121172, 11711121212, 13111111122, 17112111212

The perfect numbers containing a 0 digit are all in this sequence (33550336 and 8589869056 are shown above).

What if the change the property so that we have:

the sum of their proper divisors minus
the sum of their digits equals the number


In this case, the numbers are more numerous. In the range up to 40000 we have (permalink):

20, 66, 138, 174, 246, 282, 318, 354, 426, 534, 606, 642, 822, 1038, 1074, 1146, 1182, 1362, 1434, 1506, 1542, 1614, 1902, 2082, 2118, 2154, 2334, 2406, 2514, 2802, 3018, 3054, 3126, 3342, 3414, 3522, 3702, 4062, 4206, 4314, 5034, 5142, 5322, 6114, 7122, 7232, 7302, 8202, 8415, 10182, 10254, 10326, 10722, 11082, 11226, 11262, 11334, 11406, 11442, 12018, 12162, 12234, 12414, 12522, 13242, 13422, 13602, 14034, 14106, 14142, 14502, 16122, 17022, 19002, 20082, 20154, 20226, 20334, 20442, 20802, 21162, 21234, 21342, 21702, 22026, 22062, 22206, 22314, 22602, 23106, 23502, 24006, 24042, 24114, 25302, 26022, 27102, 30018, 30054, 30126, 30234, 30306, 30522, 31026, 31134, 31422, 31815, 32106, 32322, 32502, 33006, 33042, 33114, 34014, 34302, 35202

For example, 20 has a sum of proper divisors equal to 22 and its sum of digits is 2, thus 22 - 2 = 20. These numbers form OEIS A331096. Most of the members are even numbers but 8415 and 31815 are odd.

Friday, 6 June 2025

Binomial Number System

I made a post titled Encoding Secret Numbers only recently on the 8th of May 2025 in which I looked at how the Heinz number and Gray Code could be used to encrypt a number. An article I read today suggested another encryption method that is more arcane than the two previously mentioned. The article states that every non-negative integer n can be written as:(a1)+(b2)+(c3) where ab<cThe article goes on to say that:

You can find a, b and c much as you would find the representation in many other number systems: first find the largest possible c, then the largest possible b for what’s left, and then the remainder is a
In order to find c, we start with the observation that the binomial coefficient C(k, 3) is less than k3/6 and so c is less than the cube root of 6n. We can use this as an initial lower bound on c then search incrementally. If we wanted to be more efficient, we could do some sort of binary search.

Figure 1 shows the Python code to find a, b and c:


Figure 1: permalink

In the article the term binomial number system is used to describe this approach. Applying the code to the number associated with my diurnal age today (27823) we find that a=12, b=14 and c=56 so that:27823=(121)+(142)+(563)This encrypted version of 27823 could be represented as 12. 14. 56 with the dots being added to prevent possible ambiguity although commas or dashes or whatever could be used as well. The encrypted number has the same number of digits as the number being encrypted.

Unless someone knew about this "binomial number system" it would be impossible to guess what number was being encrypted. Once the binomial "key" is applied however, we find that:12.14.5612+91+27720=27823What about the number 1? Well, in that case, we a=b=0 and c=3 because:1=(01)+(02)+(33)0.0.3What about the number 2. In this case we have a=0, b=2 and c=3 so that:2=(01)+(22)+(33)0.2.3Of course for the number 3 we have a=1, b=2 and c=3 so that:3=(11)+(22)+(33)1.2.3Interestingly, the final comment that the author of the referenced article makes is that "you could use any number of binomial terms, not just three". One binomial term C(a, 1) just corresponds to the positive integers since:(a1)=aTwo binomial terms work as well of course. For example:(21)+(52)=2+10=12Notice that this representation of 12 (and any other number) is unique because even though:(61)+(43)=6+6=12this representation contravenes the rule that ab since a=6 and b=4. All very interesting.

27823: An Egg Drop Number

Back on the 7th of May 2021, I made a post titled The Egg Drop Numbers in which I remarked:

On June 6th, 2025 (the anniversary of D-Day by the way), I will enjoy the next egg drop number, 27823, which is the maximum number of floors for which someone, armed with 9 eggs, will be able to determine the critical floor with at most 15 trials.

Today is that day and so here is a post regarding the number created using Gemini 2.5 Pro and the following prompt:

Can you explain the mathematics behind the following statement: "the egg drop number, 27823, is the maximum number of floors for which someone, armed with 9 eggs, will be able to determine the critical floor with at most 15 trials." This has to do the famous egg breaking problem but can your explanation focus specifically on the 27823.

Here is Gemini's response: 

The Mathematics of the Egg Dropping Puzzle: The Case of 27,823

The solution to the famous egg dropping puzzle, when determining the maximum number of floors that can be tested, can be found using combinatorial mathematics, specifically with binomial coefficients.

The General Formula

The maximum number of floors, N, that can be determined with a given number of eggs, e, and a maximum number of trials, t, is given by the following summation:N(e,t)=i=1e(ti)In this formula, the term (ti) represents the binomial coefficient "t choose i", which calculates the number of unique ways to choose i items from a larger set of t items. The formula for the binomial coefficient is:(ti)=t!i!(ti)!Each term in the summation represents the number of possible outcomes for a given number of egg breaks within the allowed trials.

Calculating for 9 Eggs and 15 Trials

We are given the specific parameters:

  • Number of eggs, e=9
  • Maximum number of trials, t=15

Substituting these values into the general formula, we get:

N(9,15)=i=19(15i)This expands to the following sum:N(9,15)=(151)+(152)+(153)+(154)+(155)+(156)+(157)+(158)+(159)Next, we calculate the value of each individual binomial coefficient:

  • (151)=15
  • (152)=15!2!13!=105
  • (153)=15!3!12!=455
  •  (154)=15!4!11!=1,365
  • (155)=15!5!10!=3,003
  • (156)=15!6!9!=5,005
  • (157)=15!7!8!=6,435
  • (158)=15!8!7!=6,435
  •  (159)=15!9!6!=5,005

Finally, we sum these values to find the total number of floors:15+105+455+1,365+3,003+5,005+6,435+6,435+5,005=27,823Thus, the maximum number of floors for which one can determine the critical floor with 9 eggs and at most 15 trials is precisely 27,823.

A Misunderstanding

I was somewhat surprised to learn that I've been confusing the additive and multiplicative persistence of a number with the additive and multiplicative digital roots of the number. Let's take the number associated with my diurnal age today: 27823. The additive digital root is calculated as follows:27823224Thus the additive digital root is 4 but the additive persisence is 2, the number of steps required to reach a single digit. Similarly for the multiplicative digital root:2782367284326The multiplicative digital root is 6 but the multiplicative persistence is 4 because four steps are required to reach a single digit. 

It was just by accident that I came upon this article that awakened me to my misunderstanding. Here is the full article:

Additive and Multiplicative Persistence


Casting out nines is a well-known way of finding the remainder when a number is divided by 9. You add all the digits of a number n. And if that number is bigger than 9, add all the digits of that number. You keep this up until you get a number less than 9.

This is an example of persistence. The persistence of a number, relative to some operation, is the number of times you have to apply that operation before you reach a fixed point, a point where applying the operation further makes no change.

The additive persistence of a number is the number of times you have to take the digit sum before getting a fixed point (i.e. a number less than 9). For example, the additive persistence of 8675309 is 3 because the digits in 8675309 sum to 38, the digits in 38 sum to 11, and the digits in 11 sum to 2.

The additive persistence of a number in base b is bounded above by its iterated logarithm in base b.

The smallest number with additive persistence n is sequence A006050 in OEIS.

Multiplicative persistence is analogous, except you multiply digits together. Curiously, it seems that multiplicative persistence is bounded. This is true for numbers with less than 30,000 digits, and it is conjectured to be true for all integers.

The smallest number with multiplicative persistence n is sequence A003001 in OEIS.

Below is the Python code to compute multiplicative persistence.

def digit_prod(n):
    s = str(n)
    prod = 1
    for d in s:
        prod *= int(d)
    return prod

def persistence(n):
    c = 0
    while n > 9:
        n = digit_prod(n)
        print(n)
        c += 1
    return c   

You could use this to verify that 277777788888899 has persistence 11. It is conjectured that no number has larger persistence larger than 11.

The persistence of a large number is very likely 1. If you pick a number with 1000 digits at random, for example, it’s very likely that at least of these digits will be 0. So it would seem that the probability of a large number having persistence larger than 11 would be incredibly small, but I would not have expected it to be zero.

Here are plots to visualize the fixed points of the numbers less than N for increasing values of N.


It’s not surprising that zeros become more common as N increases. And a moments thought will explain why even numbers are more common than odd numbers. But it’s a little surprising that 4 is much less common than 2, 6, or 8.

Incidentally, we have worked in base 10 so far. In base 2, the maximum persistence is 1: when you multiply a bunch of 0s and 1s together, you either get 0 or 1. It is conjectured that the maximum persistence in base 3 is 3.

Monday, 2 June 2025

Google AI Studio and Related Disasters

I created a program in a Jupyter notebook that accepts a single number as input and then displays various properties of the number as a simple text output. I put the following prompt to Google's AI Studio:

The following code is what I created using SageMath. It is designed to accept a single number as input. Typically the number has five digits corresponding to my age in days (I'm currently 27819 days old). I'm using the program to find out interesting numerical facts about this number associated with my diurnal age. By trial and error I've had to limit the number of iterations for various tasks or else the program is too slow or crashes. For example, in finding the home prime for a number I've limited the iterations to just 10. What I want is to improve the output of this code to make it more readable and more informative in terms of additional graphs or charts? Feel free to modify the code to make it more efficient, informative or comprehensible. The code modifications can be in Python or SageMath, whatever is easier for you. I just need the program to run in a Jupyter notebook using an M1 Macbook Air and execute within say a minute or so. Any annotations, charts or tables that will enhance the output of the program will be appreciated. Any additional fun facts about the input number can be added to the program as you see fit. The key challenge is to enhance the output which is currently quite basic and limited to simple text. It's important that spacing between the different sections be consistent and that the various sections are clearly identified. I've added some commentary to each section but this can be expanded or modified if desired. 

What followed was something of a nightmare as the resulting code that was produced was full of bugs that AI Studio was never able to fix. Once I did get the code to run but many of the number properties that were displayed in my original code were no longer there. To be fair, it did produce a much improved output for the sections where it did work as can be seen in Figure 1. However, the attempts to get the code to run properly were frustrating and ultimately futile. 


Figure 1

There are numerous alternatives out there and I'll have to turn to them if I want to generate code that works. I tried ChatGPT and it revised the faulty AI Studio code but stopped at line 106 (there are about 875 lines of code) probably because I'd exceeded my free allowance of tokens. So dead end there.

Grok 3 failed to understand that the Jupyter notebook can be set to SageMath 10.3 not just Python 3 and gave the following comments:

The code you provided appears to be written for SageMath, but you're trying to run it in a Jupyter notebook, which typically uses a Python kernel with libraries like Matplotlib. This mismatch is likely causing some of the errors, as SageMath-specific functions and syntax (e.g., latex(), N(), Integer(), and certain mathematical operations) aren't directly compatible with a standard Python environment. Additionally, there are a few other issues that could lead to errors, such as undefined variables, plotting issues, and missing imports.

I'll modify the code to make it compatible with a standard Jupyter notebook environment using Python 3, while preserving its core functionality. I'll replace SageMath-specific functions with equivalent Python alternatives, ensure proper imports, and fix potential glitches.

After Grok 3 turned all the code to Python 3, it was still full of bugs and never managed to execute all the code. I'm getting the feeling that my original code, written in SageMath, is possibly at the core of the problem. When an AI tries to improve the code, using SageMath or Python, then all sorts of glitches arise because of the modifications to my original code. It would be better to build the whole code base from scratch using Python only and indicating exactly what I want. One thing I've realised is that LaTeX can be applied to the Jupyter notebook output to greatly improve readability.

It occurred to me that I lot of my code just reproduces what a site like Numbers Aplenty always publicly provides. I asked Gemini 2.5 Flash the following question:

Is it possible to create Python code that draws on the content of a site like Numbers Aplenty. For example, let's say I enter 27819 into my program. Can I get the program to then access https://www.numbersaplenty.com/27819 and extract some or all of the information from it. For example, one of the properties of the number that the site displays is "It is a junction number, because it is equal to n+sod(n) for n = 27792 and 27801". Can I get this information to show up as output in my code? If it is feasible then could you create the necessary code to do this or explain why this is not possible.

The response was encouraging:

Yes, it is absolutely possible to create Python code that draws on the content of a site like Numbers Aplenty and extracts specific information. This process is commonly known as web scraping. Numbers Aplenty doesn't seem to offer a public API (Application Programming Interface) for directly accessing its data in a structured format. This means we'll need to use web scraping techniques. 

It then went on to confidently provide code for doing this but of course it didn't work. Excuses were made and additional programs and drivers were recommended for download to remedy the problem. In short, no go. I should try other AI tools but frankly the whole process has exhausted me. I need a rest.