Thursday, 17 June 2021

Odds and Evens

Today, having turned 26372 days old, I set out finding something interesting about this number. There wasn't anything that caught my attention until I stumbled upon the information shown in Figure 1.


Figure 1

The site link that is displayed refuses to load but the purple print piqued my curiosity:

Add to n its odd digits and subtract its even ones

I realised that 26372 is special in this regard because its odd digits (3 and 7) add to 10 and its even digits (2, 6 and 2) also add to 10. The number is unaffected by this process of addition and subtraction. It might be termed stable under this process. What about other numbers that aren't stable? How many repetitions of the process are needed on average for a number to become a stable number? Are there some numbers that never become stable? What proportion of numbers are stable? That's what I set out to investigate in a SageMath program that examined the first 100,000 integers. Here is a permalink to that program. 

The output reveals that 88985, 88987 and 91055 produce record runs of 81 steps before reaching a stable number. The average run or trajectory length is 8.58. Figure 1 shows a plot of all trajectory lengths for numbers from 1 to 100000.


Figure 1: permalink

So how many numbers are stable in that range. Here is a permalink to another SageMath program that determines this. The answer turns out to 3725 or 3.725% of the numbers between 1 and 100,000. In the range from 1 to 1000, the numbers are:

112, 121, 134, 143, 156, 165, 178, 187, 211, 314, 336, 341, 358, 363, 385, 413, 431, 516, 538, 561, 583, 615, 633, 651, 718, 781, 817, 835, 853, 871

These numbers form OEIS  A036301 but there is no further analysis done.


 A036301

Numbers whose sum of even digits and sum of odd digits are equal. 

Of the 3725 numbers between 1 and 100000 that are member of OEIS A036301, 301 are prime. Here is a permalink to a program that will verify this.

I wrote another program that displays the "trajectory" or path of a number on its journey from instability to stability or looping. Here is a permalink to this program. Applied to 88985, it can be seen that the trajectory is:

88985, 88975, 88980, 88965, 88957, 88962, 88947, 88943, 88935, 88936, 88926, 88911, 88906, 88893, 88881, 88850, 88831, 88811, 88789, 88781, 88765, 88755, 88756, 88746, 88727, 88723, 88715, 88712, 88702, 88691, 88679, 88673, 88661, 88634, 88611, 88591, 88590, 88588, 88561, 88545, 88535, 88532, 88522, 88507, 88503, 88495, 88489, 88470, 88457, 88449, 88434, 88413, 88397, 88400, 88380, 88359, 88360, 88341, 88325, 88315, 88308, 88287, 88268, 88236, 88215, 88203, 88188, 88157, 88154, 88140, 88121, 88105, 88095, 88093, 88089, 88074, 88061, 88040, 88020, 88002, 87984, 87980, 87980

After 81 steps, the stable number 87980 is reached. The table in Figure 2 shows that the numbers near 88985 and 88987 have mostly near-record trajectory lengths.


Figure 2

However, Figure 3 shows that 91055 is very much a singleton.


Figure 3

If the range is extended to 200,000, a new record of 91 is reached with 158893. The trajectory is:

158893, 158895, 158899, 158907, 158921, 158927, 158939, 158958, 158962, 158961, 158963, 158967, 158975, 158994, 159006, 159015, 159036, 159048, 159051, 159072, 159092, 159114, 159127, 159148, 159152, 159171, 159195, 159225, 159241, 159251, 159270, 159290, 159312, 159329, 159354, 159373, 159401, 159413, 159428, 159429, 159447, 159461, 159467, 159479, 159506, 159520, 159538, 159553, 159581, 159594, 159619, 159638, 159642, 159645, 159655, 159674, 159686, 159681, 159683, 159687, 159695, 159718, 159733, 159761, 159778, 159799, 159839, 159858, 159862, 159861, 159863, 159867, 159875, 159894, 159906, 159924, 159942, 159960, 159978, 160001, 159997, 160037, 160042, 160031, 160030, 160028, 160013, 160012, 160006, 159995, 160033, 160034, 160028

Interestingly, a stable number is not reached but instead a loop arises: 160028, 160013, 160012, 160006, 159995, 160033, 160034, 160028. So some numbers attain "stability" (such as 88985) while others enter a loop (such as 158893). 

Figure 4 is a plot of all trajectory lengths from 1 to 200,000:


Figure 4

Note that the average trajectory length has increased from 8.58 to 10.6 which makes sense. As numbers get bigger, it should take them longer to settle on a stable number or to enter a loop. It's difficult to explore beyond 200,000 because SageMathCell times out. 

I developed another algorithm to check on the relative proportions of numbers that end up as stable numbers versus ending in a loop. Here is a permalink. The results are as follows:

  • total of numbers ending in a stable number is 58977 up to 100000 or 59.0 percent
  • total of numbers ending in loop is 37298 up to 100000 or 37.3 percent
  • total number of stable numbers up to 100000 is 3725 or 3.73 percent
Figure 5 shows a graphical representation:

Figure 5

One general point to note about this odd-even recursive process is that there are five odd digits (1, 3, 5, 7 and 9) totalling 25 and four even digits (2, 4, 6 and 8) totalling 20. The process thus favours the progressive numbers getting larger rather than smaller. 

Some stable numbers attract unstable numbers far more strongly than others. Figure 6 shows a table listing the top "attractors". As can be seen, 87980 might be termed the Great Attractor with 881 unstable numbers being attracted to it. Here is a permalink to the program that created the information.


Figure 6: Google Sheet Link

Looking at all the data in the spreadsheet, 134 stands out because even though it is a small number, it attracts 74 unstable numbers.

Overall, it's clear than in terms of this odd-even recursive process there are three types of numbers:
  • numbers that remain unchanged by the process e.g. 112. 
  • numbers that are changed by the process and in the end become unchangeable numbers e.g. 114 becomes 112 in only one step of the process.
  • numbers that are changed by the process and in the end become trapped in a loop e.g. 5 which has a trajectory of 10, 11, 13, 17, 23, 24, 18, 11 and so becomes caught in a loop and never becomes an unchangeable.
We might call the first type of number immutable and the two other types mutable but differentiated by a prefix i-mutable and v-mutable where v stands for vortex (that these types of numbers are drawn into). So 112 could be described as an immutable number, 114 as i-mutable and 5 as v-mutable. These differentiators are speculative and might change but they do serve to clearly identify each type of number.

Another nomenclature that I considered was that of attractor and captive. It's as if the gravitational pull of an attractor (an immutable number in my previous nomenclature) pulls the i-mutable numbers to them and so in a sense they are captives of the attractor. The v-mutable numbers are also attracted by the vortices comprised of a series to two or more looping chains of numbers, each member of which might be termed a vortical. This could be explained as follows:
  • 112 is an attractor
  • 114 is a captive of the attractor 112
  • 5 is a captive of the vortex {10, 11, 13, 17, 23, 24, 18}
  • 10, 11, 13, 17, 23, 24 and 18 are vorticals comprising the vortex
In the past, my first response to a number was to consider whether it was prime or composite whereas now I'll be inclined to also consider whether it's mutable or immutable and, if the former, whether it is i-mutable or v-mutable OR I might just settle on attractor, captive and vortical.

No comments:

Post a Comment