Showing posts with label steps. Show all posts
Showing posts with label steps. Show all posts

Saturday, 12 July 2025

13x+1 Record Breaker

Trajectory length record breakers for the 3\(x\) + 1, 5\(x\) + 1, 7\(x\) + 1, 11\(x\) + 1, 13\(x\) + 1 and 17\(x\) + 1 Collatz mappings are a fairly exclusive set of numbers and its members from 27859 to 40000 are 27859, 28927, 30301, 30771, 32326, 32581, 34239, 35556, 35655, 35803, 37647, 38030, 39053, 39254 and 39281. Why start at 27859? Well this is the number associated with my diurnal age and the next celebration of such an event is about three years away when I reach 28927 days old. 27859 is associated with the 13\(x\) + 1 mapping where the numbers that mark the record breaking trajectory lengths are shown in Figure 1.


Figure 1: see blog post

Figure 2 shows the trajectory for 27859 using a logarithmic scale for the vertical axis.


Figure 2: permalink

The trajectory is as follows ending in a 7, 1, 14, 7 loop. The maximum value reached is an impressive \( \textbf{1,004,280,846,804} \). That's just over a trillion. That's why a logarithmic scale was needed for the vertical axis!

27859, 362168, 181084, 90542, 45271, 588524, 294262, 147131, 1912704, 956352, 478176, 239088, 119544, 59772, 29886, 14943, 4981, 64754, 32377, 420902, 210451, 2735864, 1367932, 683966, 341983, 4445780, 2222890, 1111445, 222289, 2889758, 1444879, 18783428, 9391714, 4695857, 61046142, 30523071, 10174357, 132266642, 66133321, 859733174, 429866587, 5588265632, 2794132816, 1397066408, 698533204, 349266602, 174633301, 2270232914, 1135116457, 14756513942, 7378256971, 95917340624, 47958670312, 23979335156, 11989667578, 5994833789, 856404827, 11133262752, 5566631376, 2783315688, 1391657844, 695828922, 347914461, 115971487, 1507629332, 753814666, 376907333, 34264303, 445435940, 222717970, 111358985, 22271797, 289533362, 144766681, 1881966854, 940983427, 12232784552, 6116392276, 3058196138, 1529098069, 19878274898, 9939137449, 129208786838, 64604393419, 839857114448, 419928557224, 209964278612, 104982139306, 52491069653, 4771915423, 433810493, 5639536410, 2819768205, 939922735, 187984547, 2443799112, 1221899556, 610949778, 305474889, 101824963, 1323724520, 661862260, 330931130, 165465565, 33093113, 430210470, 215105235, 71701745, 14340349, 186424538, 93212269, 1211759498, 605879749, 7876436738, 3938218369, 51196838798, 25598419399, 3656917057, 47539921742, 23769960871, 309009491324, 154504745662, 77252372831, 1004280846804, 502140423402, 251070211701, 83690070567, 27896690189, 362656972458, 181328486229, 60442828743, 20147609581, 1831600871, 23810811324, 11905405662, 5952702831, 1984234277, 25795045602, 12897522801, 4299174267, 1433058089, 18629755158, 9314877579, 3104959193, 443565599, 5766352788, 2883176394, 1441588197, 480529399, 68647057, 892411742, 446205871, 5800676324, 2900338162, 1450169081, 18852198054, 9426099027, 3142033009, 40846429118, 20423214559, 1856655869, 24136526298, 12068263149, 4022754383, 52295806980, 26147903490, 13073951745, 4357983915, 1452661305, 484220435, 96844087, 1258973132, 629486566, 314743283, 4091662680, 2045831340, 1022915670, 511457835, 170485945, 34097189, 4871027, 695861, 9046194, 4523097, 1507699, 19600088, 9800044, 4900022, 2450011, 31850144, 15925072, 7962536, 3981268, 1990634, 995317, 12939122, 6469561, 924223, 12014900, 6007450, 3003725, 600745, 120149, 1561938, 780969, 260323, 37189, 483458, 241729, 3142478, 1571239, 20426108, 10213054, 5106527, 66384852, 33192426, 16596213, 5532071, 71916924, 35958462, 17979231, 5993077, 77910002, 38955001, 506415014, 253207507, 36172501, 470242514, 235121257, 33588751, 4798393, 62379110, 31189555, 6237911, 81092844, 40546422, 20273211, 6757737, 2252579, 321797, 45971, 597624, 298812, 149406, 74703, 24901, 323714, 161857, 2104142, 1052071, 13676924, 6838462, 3419231, 44450004, 22225002, 11112501, 3704167, 48154172, 24077086, 12038543, 1094413, 14227370, 7113685, 1422737, 18495582, 9247791, 3082597, 440371, 5724824, 2862412, 1431206, 715603, 102229, 1328978, 664489, 94927, 13561, 176294, 88147, 1145912, 572956, 286478, 143239, 1862108, 931054, 465527, 6051852, 3025926, 1512963, 504321, 168107, 2185392, 1092696, 546348, 273174, 136587, 45529, 4139, 53808, 26904, 13452, 6726, 3363, 1121, 14574, 7287, 2429, 347, 4512, 2256, 1128, 564, 282, 141, 47, 612, 306, 153, 51, 17, 222, 111, 37, 482, 241, 3134, 1567, 20372, 10186, 5093, 463, 6020, 3010, 1505, 301, 43, 560, 280, 140, 70, 35, 7, 1, 14, 7

Wednesday, 2 July 2025

Prime Factor Sequences

I'm surprised I've not come across this type of sequence before. It has two variants and they are generated iteratively as follows:

  • number --> sum of prime factors without multiplicity
    For example, 24 with factors of 2 and 3 gives 5 and terminates after just one step

  • number --> sum of prime factors with multiplicity
    For example, 24 with factors of 2, 2, 2 and 3 gives 11 and terminates after just one step
Larger numbers of course take more than one step to terminate and it's of interest to consider those numbers that set records in term of trajectory lengths. In this context, let's consider OEIS A047830.


A047830  least number which becomes prime after exactly \(n\) iterations of f(\(x\)) = sum of prime factors of \(x\).


The members of this sequence are 4, 14, 26, 62, 134, 393, 1774, 13682, 41037 up to 100,000. The trajectories are shown in Figure 1 with length indicating the number of steps or iterations:


Figure 1: permalink

If the sum of prime factors with multiplicity is considered then we get OEIS A121360 with sequence members 1, 8, 14, 26, 62, 134, 393, 1257, 4659, 9314, 27933 up to 100,000. The trajectories are shown in Figure 2 with length indicating the number of steps or iterations:



Figure 2: permalink

The algorithms used to find the trajectories of record lengths can be easily modified to find numbers with trajectories of a specified length (number of steps or iterations). For example, how many numbers in the range up to 40000 require eight steps to reach a prime under the sum of prime factors without multiplicity algorithm. Here are the numbers (with 13682 being the first as we know already from Figure 1):

13682, 18002, 19137, 22934, 24014, 24787, 27364, 27849, 30062, 30993, 32577, 33477, 35410, 35798, 36004, 36398, 36706, 39206

These numbers are the initial members of OEIS A047827. Figure 3 shows the details of their trajectories:


Figure 3: permalink

Saturday, 31 May 2025

Self Avoiding Walks

In my previous post titled Random Walks, I made mention of self-avoiding walks and for this post I asked Gemini 2.5 Pro to implement the following program:

Write a program in Python that will generate and display a random but self avoiding walk on a square grid of points. The size of the grid can be 100 x 100 points but this should be easily modifiable. The walk should start at the bottom left hand side and proceed to the top right hand side. Each step can be up or down from one point to the next or left or right from one point to the next but movement is contrained within the grid of points. The number of steps required to complete the walk should be prominently displayed at the top or bottom of the display.

It dutifully did this and here is the Canvas link. Here was Gemini's thinking about the desired program.

Okay, I'll provide you with a Python program that generates and displays a random self-avoiding walk on a square grid. This program uses a recursive backtracking algorithm to find a path from the bottom-left corner to the top-right corner. The grid size is easily modifiable.

Here's how the program works:

  1. Grid and Path Representation: The grid is implicitly defined by its size. The path is stored as a list of (x, y) coordinate tuples.
  2. Self-Avoiding Walk Generation:
    • It starts at (0,0) (bottom-left).
    • The target is (grid_size-1, grid_size-1) (top-right).
    • A recursive function attempts to find a path:
      • It marks the current cell as visited and adds it to the path.
      • If the current cell is the target, the path is found.
      • Otherwise, it randomly shuffles the possible directions (Up, Down, Left, Right).
      • For each valid direction (within bounds and not previously visited in the current path), it makes a recursive call.
      • If a recursive call returns success, the path is propagated up.
      • If all directions from the current cell lead to dead ends, it backtracks by removing the cell from the path and unmarking it as visited.
    • Due to the potential for deep recursion, especially on large grids (like 100x100), the program attempts to increase Python's recursion limit. Note that for very large grids, this process can still be computationally intensive and take some time.
  3. Display:
    • matplotlib is used to visualize the walk.
    • The path is plotted on the grid.
    • Start and end points are highlighted.
    • The number of steps taken is displayed in the plot title.

I will now generate the Python code for you.

Self-Avoiding Random Walk Generator

This Python script defines two main functions: generate_self_avoiding_walk to create the path and display_walk to visualize it using matplotlib.

To use this code:

  1. Save it as a Python file (e.g., saw_generator.py).
  2. Make sure you have matplotlib installed (pip install matplotlib).
  3. Run it from your terminal: python saw_generator.py.
  4. You can easily change the GRID_SIZE variable in the if __name__ == "__main__": block to generate walks on grids of different sizes. Keep in mind that larger grids (e.g., 100x100) will take significantly longer to compute and may require a high recursion limit, which the script attempts to set.

The generated plot will show the random walk, and the title will include the number of steps taken.

I should try to implement this program myself using SageMathCell. Running the program on SageMathCell using only for a 20m x 20 grid will often cause it to time out and even in my Jupyter notebook I often needed to terminate the process because it was taking too long. However, the program often generates a walk quite quickly and Figures 1 and 2 show typical outputs.


Figure 1: permalink


Figure 2: permalink

The difference between Figures 1 and 2 in this post compared to Figure 9 in my previous post is that the latter traverses every point in the grid and not just a random selection of them. Gemini will write a program to do this but as it explains:
Finding a Hamiltonian path is an NP-complete problem. This means that for larger grids, the time required to find such a path can grow extremely rapidly. The provided recursive backtracking algorithm will explore many possibilities. For a small grid (e.g., 3x3, 4x4, maybe 5x5), it might find a solution in a reasonable time.

Here is a Canvas link to the code. Figure 3 shows a typical output using a 4 x 4 grid.


Figure 3

Wednesday, 23 April 2025

Descent to Zero

The number associated with my diurnal age today, \( \textbf{27779} \), has the interesting property that it is the smallest number that takes 22 steps to reach 0 under "\(k \rightarrow \) max product of two numbers whose concatenation is \(k\)". The possible concatenatable pairs and their products for 27779 are:

  • 2 * 7779 = 15558
  • 27 * 779 = 21033
  • 277 * 79 = 21883
  • 2777 * 9 = 24993
We see that 24993 is the maximum product and we repeat the process using this number as our starting point:

  • 2 * 4993 = 9986
  • 24 * 993 = 23832
  • 249 * 93 = 23157
  • 2499 * 3 = 7497
The maximum product is 23832 and so this becomes the new number and the process continues until we reach 0 after 22 steps. The progression is as follows (permalink):

27779, 24993, 23832, 19136, 11478, 9176, 6916, 5496, 5184, 4284, 3528, 2816, 1686, 1376, 988, 792, 644, 264, 128, 96, 54, 20, 0


27779 is a member of OEIS A035932: smallest number that takes \(n\) steps to reach 0 under "\( k \rightarrow \) max product of two numbers whose concatenation is \(k\)". The initial members of this sequence are:

0, 1, 11, 26, 39, 77, 117, 139, 449, 529, 777, 1117, 2229, 2982, 4267, 4779, 5319, 5919, 8693, 12699, 14119, 17907, 27779, 47877, 80299, 103199, 135199, 274834, 293938, 312794, 606963, 653993, 773989, 1160892, 1296741, 1616696, 1986576

This permalink will check for the smallest number once the number of steps is specified. When writing the code the convention is that you add a condition to handle single-digit numbers. A common rule for sequences like this that aim to reach 0 is that single-digit numbers (other than 0) map to 0 in the next step. So looking at the above sequence we see following progressions to 0 beginning with 0 that requires zero steps (permalink):
  • 0
  • 1, 0
  • 11, 1, 0
  • 26, 12, 2, 0
  • 39, 27, 14, 4, 0
  • 77, 49, 36, 18, 8, 0
  • 117, 77, 49, 36, 18, 8, 0
  • 139, 117, 77, 49, 36, 18, 8, 0
  • 449, 396, 288, 224, 88, 64, 24, 8, 0
  • 529, 468, 368, 288, 224, 88, 64, 24, 8, 0
  • 777, 539, 477, 329, 288, 224, 88, 64, 24, 8, 0
  • 1117, 777, 539, 477, 329, 288, 224, 88, 64, 24, 8, 0
  • 2229, 1998, 1862, 1116, 666, 396, 288, 224, 88, 64, 24, 8, 0
  • 2982, 2378, 1896, 1728, 1376, 988, 792, 644, 264, 128, 96, 54, 20, 0

Monday, 19 August 2024

Up and Down the Mountain

The number (27532) associated with my diurnal age today has an interesting aliquot sequence consisting of 210 steps that reaches a maximum value of 210998991785527991104 before beginning its descent to 1 and then 0. Here is the sequence:

27532, 20656, 19396, 17256, 25944, 43176, 80664, 121056, 224688, 378448, 494512, 495504, 1012336, 1181968, 1182960, 2995344, 6599280, 14542224, 25693296, 43014360, 90683160, 185451240, 425275800, 940708200, 1975489080, 4299600360, 9787608600, 30598377960, 62464790040, 124929580440, 322138579560, 782543654040, 1590997194600, 3789466067640, 8612422885320, 17245450814520, 34491361043400, 72967727801400, 156608347258440, 511373352229560, 1193233352540040, 3238776242618040, 7557144566112360, 17008403414134680, 43343078672652120, 98245289952891720, 225485753448117420, 499595022460258740, 1016220356878620060, 2146302511659329220, 4365805465306640340, 8912079582213674700, 19057572060429045492, 30451944343316954508, 46523803857845347256, 43522269061507054024, 41538397982866392056, 39514226617193027944, 34588280875055182556, 26164545907884419524, 19879736397904788476, 15278939116317231844, 13034324430483320084, 9787165489989868000, 14259900118915247504, 13373492843095311856, 12537649540401854896, 11754756084394941888, 20702681104040261952, 35918311240577926848, 63312611494171175232, 104258325352849123008, 210998991785527991104, 207702132538879116370, 169624609562080576430, 135726953604303765970, 148468761008721086318, 131290689970046993554, 93931702661206931822, 67094073456072645490, 63039859860977978510, 66642137567319577426, 33622680034706422574, 20453938384323035986, 10514105806833405614, 5257053195212561074, 2628558999616292174, 1319289459782004154, 678859735840149446, 432198199089642970, 372584654387623790, 423185411483397010, 447367434996734126, 335199506688516274, 241133173013919566, 129392986488928594, 69210234498425006, 49442455265686354, 31628275705499822, 17569420012749490, 15482802556130510, 12912073075113586, 8615431262813582, 4307715631406794, 2182074293639066, 1091037352376614, 545519846484554, 272807528144026, 136403764072016, 172028060840272, 246230032928432, 322698987259984, 302536923800196, 440536222376284, 330402166782220, 469768933828340, 521929534249180, 574124185108340, 632252256474700, 811995150775220, 893194665852784, 856062512768896, 913869490270304, 885311068699420, 1142969402332388, 857227051749298, 428613525874652, 321536752958884, 279499971575516, 235369388238244, 208212125817436, 207269989503284, 155452492127470, 125699432957330, 100559546365882, 50279927860454, 25488855451066, 20776630073990, 21985463380090, 25902201396614, 14856456204922, 7434249373850, 7457427003070, 7186247839538, 4160459275582, 2399770256450, 2707938109054, 1364410976426, 711333048214, 360723394754, 183945042814, 115353159818, 74577627382, 39307973018, 20226433030, 16181146442, 8167141114, 5307725702, 2873228938, 1532896886, 800767234, 435474206, 217915858, 109021742, 58683250, 51172262, 26101738, 16062650, 15625798, 8569082, 5026822, 2524250, 2417830, 1934282, 1381654, 746954, 459706, 282938, 144250, 126254, 63130, 53510, 42826, 39254, 22786, 11396, 14140, 20132, 20188, 21308, 21364, 22526, 16114, 11534, 6226, 3998, 2002, 2030, 2290, 1850, 1684, 1270, 1034, 694, 350, 394, 200, 265, 59, 1, 0

Figure 1 shows these values plotted on a logarithmic vertical scale that necessarily ends in 1 not 0 because we are working with logarithms. The sequence is embedded in the graph.


Figure 1: permalink (not annotated)

The logarithmic graph is preferable to the non-logarithmic because of the massive spike that makes the smaller values invisible. See Figure 2.


Figure 2: permalink

In an earlier post the 15th August 2024, I posted about Infinite, Aperiodic Aliquot Series but this series is finite as shown but takes a while to terminate. I'll continue to monitor the aliquot sequences generated by the numbers associated with my diurnal age and report on any that involve a large number of steps to terminate or for which no termination can be demonstrated.

In earlier posts, I've mentioned aliquot sequences of various types. These posts include:

Thursday, 15 February 2024

Diurnal Age Meets Conway's Game Of Life

 I've written about Conway's Game of Life in two recent posts:

I've been playing around with an app called "Life" on my iPhone that allows the game to be run but I prefer on browser-based app that I can access from my laptop. To that end, I've been playing around with one of three websites recommended by Gemini:
This website utilizes the popular "Golly" simulation software, offering advanced features like pattern libraries, scripting, and different grid geometries. You can save and export your simulations in various formats.
This website allows you to draw patterns directly on the grid with an intuitive interface. While it lacks advanced features, it's great for quick visualizations and sharing creations.

So in this post, I'm looking at the first of the recommendations and playing around with a new idea. I want to investigate how the number associated with my diurnal age behaves under the Game of Life rules. The number for today, 27346, is shown in Figure 1. All the digits from 0 to 9 can be created using a 3 x 5 pixel grid, the smallest possible size.


Figure 1

The rules lead, after 125 steps, to the image shown in Figure 2:


Figure 2

What would be interesting to keep track of are the number of steps required to reach a stable state. It's clear that the stable states arising from numbers are not unique. For example 16161 will end up the same as 19191 if we don't regard mirror images, rotations and reflections as different. However, most numbers should result in stable states that are different from one another. I can attach images of these stable states to my Airtable database. 

I'll explore the other two Gemini recommendations later. Any particularly interesting stable states or record number of steps arising from these diurnal age investigations can be the subject of future posts. In the case of 27346, we can say that the stable state consists of five blocks (the simplest still life) and one hive or beehive (the second most common still life).

 

This ongoing, daily exercise is a great way to deepen ones understanding of a topic. It was only through my adherence to the investigation of the number associated with my diurnal age that I widened and deepened my understanding of number theory. It's a great maxim: once a day but everyday and can be and should be applied to more aspects of my daily life.

Monday, 19 September 2022

Look and Count Sequence

On February 10th 2017, I posted about the Look and Say Sequence. After rereading that post, I thought about a variation on that idea and I've called it the Look and Count Sequence. Let's use 1 and example. To begin with there is only one 1 and so we write 11. Now there are two ones and so we write 21. So far it is the same as the Look and Say Sequence.

Here's where it differs. Instead of saying "one two and one one" (1211), we count how many ones, how many twos etc. in order from lowest to highest. Thus 21 becomes "one one and one two" (1112). Now we have "three ones and one two" (3112) which in turn becomes "two ones, one two and one three" (211213). I've written an algorithm to generate the sequence of numbers that result from using 1 as the starting point (permalink). Here it is:

1, 11, 21, 1112, 3112, 211213, 312213, 212223, 114213, 31121314, 41122314, 31221324, 21322314, 21322314

As can be seen the sequence quickly terminates when it reaches 21322314. What about using 2 as the starting point? The result is this sequence enters the one above at the number 1112:

2, 12, 1112, 3112, 211213, 312213, 212223, 114213, 31121314, 41122314, 31221324, 21322314, 21322314

Trying 3, it can be seen that again the sequences overlap and the end result is the same.

3, 13, 1113, 3113, 2123, 112213, 312213, 212223, 114213, 31121314, 41122314, 31221324, 21322314, 21322314

Trying 4, the same end result is reached and even more quickly.

4, 14, 1114, 3114, 211314, 31121314, 41122314, 31221324, 21322314, 21322314 

With 5, the result must be different and it is but the sequence again quickly terminates.

5, 15, 1115, 3115, 211315, 31121315, 41122315, 3122131415, 4122231415, 3132132415, 3122331415, 3122331415

When we investigate 6, 7, 8 and 9, it can be seen that the pattern in the same.

6, 16, 1116, 3116, 211316, 31121316, 41122316, 3122131416, 4122231416, 3132132416, 3122331416, 3122331416

7, 17, 1117, 3117, 211317, 31121317, 41122317, 3122131417, 4122231417, 3132132417, 3122331417, 3122331417

8, 18, 1118, 3118, 211318, 31121318, 41122318, 3122131418, 4122231418, 3132132418, 3122331418, 3122331418

9, 19, 1119, 3119, 211319, 31121319, 41122319, 3122131419, 4122231419, 3132132419, 3122331419, 3122331419

What if we take an arbitrary and larger number, let's say 78651154? The result is a two step loop (5142131415261718 --> 6122132425161718 --> 5142131415261718):

78651154, 211425161718, 51221415161718, 61221425161718, 51321415261718, 5122131425161718, 6132131425161718, 6122231415261718, 5142131415261718, 6122132425161718, 5142131415261718

Even if we take an unusual number like 999999999999, the result is also a two step loop:

999999999999, 129, 111219, 411219, 31121419, 4112131419, 5112132419, 412213141519, 512213241519, 413213142519, 412223241519, 314213241519, 412223241519

So far I've not considered numbers with 0 as a digital. If we try 1004056906, the result is the same two step loop:

1004056906, 401114152619, 10511224151619, 10612214251619, 10513214152619, 1051221314251619, 1061321314251619, 1061222314152619, 1051421314152619, 1061221324251619, 1051421314152619

So it seems that, no matter what the starting number, the sequence of terms generated quickly terminates. This is true for even large numbers like:

101111011101100222222222222222222222222222222222

The steps leading to another two step loop are:
  1. 101111011101100222222222222222222222222222222222
  2. 50101332
  3. 2021122315
  4. 1031421315
  5. 104112231415
  6. 105122132415
  7. 104132131425
  8. 104122232415
  9. 103142132415
  10. 104122232415
It's interesting to explore what numbers set records for the number of steps required before they terminate. Here is what I found for the range of numbers up to 100,000 (permalink):

1 requires 13 steps
60 requires 14 steps
70 requires 15 steps
80 requires 16 steps
109 requires 17 steps
2008 requires 18 steps
2009 requires 20 steps
9009 requires 21 steps

Tuesday, 2 August 2022

Erase or Triple Protocol

There's always something new to discover under the mathematical sun and today I encountered an interesting protocol that can be applied to numbers. It works as follows:

The "Erase or triple" protocol describes how to transform an integer \(K\) into an integer \(L\): if \(K\) has 2 or more identical digits, erase them to get \(L\) (1201331 becomes 20); if \(K\) has no duplicate digits, triple \(K\) to get \(L\) (20 becomes 60). Some integers disappear immediately (like 11, 2002 or 1919188), other enter into a loop if you apply this protocol to the successive results. Link.

My diurnal age today was 26784, a number that is a member of OEIS A300150: "erase or triple": list of the successive integers that produce the next "altitude" record. The initial numbers and their associated "altitude" records are as follows (the numbers are shown first in bold and records second - permalink):

(1, 17010), (10, 65610), (23, 121743), (176, 1154736), (1760, 1283040), (2183, 1591407), (2640, 5773680), (23976, 5826168), (24056, 5845608), (26784, 6508512), (29087, 7068141), (29701, 7217343), (30715, 7463745), (31456, 7643808), (32145, 7811235)

Thus the numbers associated with these maximum values are:

1  10  23  176  1760  2183  2640  23976  24056  26784  29087  29701  30715  31456  32145  

 Let's take 26784 as an example. It's trajectory is as follows:

26784, 80352, 241056, 723168, 2169504, 6508512, 60812, 182436, 547308, 1641924, 692, 2076, 6228, 68, 204, 612, 1836, 5508, 8, 24, 72, 216, 648, 1944, 19, 57, 171, 7, 21, 63, 189, 567, 1701, 70, 210, 630, 1890, 5670, 17010, 7

Note that trajectory enters a loop once 7 is reached for the second time. The trajectory has a length of 39 steps. It's graph is shown in Figure 1:


Figure 1: permalink

176, from the above list of record breakers, is an example of a number that eventually reaches 0. It's trajectory is as follows:

176, 528, 1584, 4752, 14256, 42768, 128304, 384912, 1154736, 54736, 164208, 492624, 96, 288, 2, 6, 18, 54, 162, 486, 1458, 4374, 37, 111, 0

The graph of its trajectory is shown in Figure 2 and consists of 25 steps: 


Figure 2: permalink

23, from the above list of record breakers, is an example of a number that ends in an 89 loop. It's trajectory of length 21 steps is as follows:

23, 69, 207, 621, 1863, 5589, 89, 267, 801, 2403, 7209, 21627, 167, 501, 1503, 4509, 13527, 40581, 121743, 2743, 8229, 89

The graph of its trajectory is shown in Figure 3:


Figure 3: permalink

29701, from the above list of record breakers, is an example of a number that ends in a 5 loop. It's trajectory, of length 22 steps, is as follows:

29701, 89103, 267309, 801927, 2405781, 7217343, 214, 642, 1926, 5778, 58, 174, 522, 5, 15, 45, 135, 405, 1215, 25, 75, 225, 5

The graph of its trajectory is shown in Figure 4:


Figure 4: permalink

For any number, there are only four possible end results for its trajectory: either it reaches 0 or it enters a 5, 7 or 89 loop. Returning to OEIS A300150: "erase or triple": list of the successive integers that produce the next "altitude" record. The sequence is finite and has 628 terms, with a(628) = 3291768054 (pandigital); a(628) reaches the maximum possible "altitude" 29625912486.

When dealing with trajectories, we are interested in the length of the trajectories as well as the maxima and so a reasonable question to ask is what numbers produce trajectories of record length? It turns out that these are the records up to 40,000 with numbers first in bold and trajectory lengths following (permalink):
[(1, 29), (16, 32), (26, 35), (56, 37), (134, 39), (218, 41), (241, 45), (871, 46), (8059, 47), (14957, 48)]

Thus the numbers associated with the record trajectory lengths are:

1  16  26  56  134  218   241  871   8059  14957 

 The trajectory of 14957, with a trajectory length of 48, is as follows:

14957, 44871, 871, 2613, 7839, 23517, 70551, 701, 2103, 6309, 18927, 56781, 170343, 1704, 5112, 52, 156, 468, 1404, 10, 30, 90, 270, 810, 2430, 7290, 21870, 65610, 510, 1530, 4590, 13770, 130, 390, 1170, 70, 210, 630, 1890, 5670, 17010, 7, 21, 63, 189, 567, 1701, 70

This 70 loop is actually a part of the 7 loop as can be seen below:

7, 21, 63, 189, 567, 1701, 70, 210, 630, 1890, 5670, 17010, 7 

The graph of its trajectory is shown in Figure 5:


Figure 5: permalink

This "erase or triple" protocol could be generalised so if the digits of a number satisfy a certain criterion then they are erased to form a new number or, if the criterion is not met, the number is modified in some way. For example, suppose the number contains prime digits (2, 3, 5 or 7). If it does, then these digits are erased. If the number does not contain any prime digits, then the number is squared and 1 is added.

Let's use 14857 as a test number. It contains the prime digits 5 and 7 so these are erased to leave 148. This number contains no prime digits so it becomes 148 x 148 + 1 = 21905. We erase the 2 and the 5 to get 190 which becomes 190 x 190 + 1 = 36101 and so on. I could continue but the trajectory under this new protocol is best dealt with by creating an appropriate algorithm (permalink).

Using the algorithm, the trajectory turns out to have a length of 7 and is:

14857, 148, 21905, 190, 36101, 6101, 37222202, 0

Once 37222202 is reached and all the prime digits are erased, we are left with 0. This seems to be the fate of many numbers but not all. For example, while 6, 66 and 666 all end in 0, 6666 increases rapidly without bound. It might be better to double the number and add 1 rather than squaring it and adding 1. However, I'm digressing. This new protocol and variations thereof could serve as the basis for a future post but that's enough for this post.

In closing, I'll just observe that protocols like these, where we are manipulating the digits of the number in some way, fall into the realm of recreational mathematics rather than serious mathematics. Not only are they specific to the number base 10 but they also ignore, in the first step, the place value of the digits and acknowledge only the face value. Nonetheless, it's fun to explore the resultant trajectories when the different protocols are applied.

Saturday, 12 March 2022

Second Order Odds and Evens Trajectory for Numbers 1 to 99

In my previous post titled Higher Order Odds and Evens Trajectory, I looked specifically at the trajectory of the number 26638 under the recursive rule that:

number --> number + \( \sum d_o^k - \sum d_e^k \) with \(k \geq 1\)

where \( d_o^k \) are the number's odd digits raised to the power \( k\) and \( d_e^k \) are the number's even digits raised to the power \( k\).  In that post, I looked at the behaviour for \(2 \leq k \leq 5 \). I've looked at the case of \(k=1\) for a wide variety of numbers in several posts back in 2021 so in this post I'm focusing on values of \(k=2\) and looking only at the numbers from 1 to 99. Thus the recursive rule here is:

number --> number + \( \sum d_o^2 - \sum d_e^2 \) 

The trajectory of 1 when \(k=2\) requires 35 steps to reach the loop {327, 381}, acquiring a maximum value of 428 in the process. See Figure 1.


Figure 1

The full details of the trajectory of 1 are as follows:

1, 2, -2, -6, -42, -62, -102, -105, -79, 51, 77, 175, 250, 271, 317, 376, 398, 424, 388, 269, 310, 320, 325, 355, 414, 383, 337, 404, 372, 426, 370, 428, 344, 321, 327, 381, 327

The trajectory of 2 is almost identical to that of 1 after only one step (shown in blue):

2, -2, -6, -42, -62, -102, -105, -79, 51, 77, 175, 250, 271, 317, 376, 398, 424, 388, 269, 310, 320, 325, 355, 414, 383, 337, 404, 372, 426, 370, 428, 344, 321, 327, 381, 327

The trajectory of 3 eventually overlaps the trajectory of 1 and 2 (shown in blue):

3, 12, 9, 90, 171, 222, 210, 207, 252, 269, 310, 320, 325, 355, 414, 383, 337, 404, 372, 426, 370, 428, 344, 321, 327, 381, 327

The trajectory of 4 also overlaps the trajectory of 1 (shown in blue) and is 49 steps in length:

4, -12, -15, 11, 13, 23, 28, -40, -56, -67, -54, -45, -36, -63, -90, -9, 72, 117, 168, 69, 114, 100, 101, 103, 113, 124, 105, 131, 142, 123, 129, 207, 252, 269, 310, 320, 325, 355, 414, 383, 337, 404, 372, 426, 370, 428, 344, 321, 327, 381, 327

The trajectory of 5 is quite short, at 22 steps, and it too overlaps the trajectory of 1 (shown in blue):

5, 30, 39, 129, 207, 252, 269, 310, 320, 325, 355, 414, 383, 337, 404, 372, 426, 370, 428, 344, 321, 327, 381, 327

The trajectory of 6 is 42 steps long and also overlaps the trajectory of 1 (shown in blue):

6, -30, -21, -24, -44, -76, -63, -90, -9, 72, 117, 168, 69, 114, 100, 101, 103, 113, 124, 105, 131, 142, 123, 129, 207, 252, 269, 310, 320, 325, 355, 414, 383, 337, 404, 372, 426, 370, 428, 344, 321, 327, 381, 327

The trajectory of 7 is 29 steps in length and overlaps the trajectory of 1 (shown in blue):

7, 56, 45, 54, 63, 36, 9, 90, 171, 222, 210, 207, 252, 269, 310, 320, 325, 355, 414, 383, 337, 404, 372, 426, 370, 428, 344, 321, 327, 381, 327

The trajectory of 8 is 42 steps in length and overlaps the trajectory of 1 (shown in blue):

8, -56, -67, -54, -45, -36, -63, -90, -9, 72, 117, 168, 69, 114, 100, 101, 103, 113, 124, 105, 131, 142, 123, 129, 207, 252, 269, 310, 320, 325, 355, 414, 383, 337, 404, 372, 426, 370, 428, 344, 321, 327, 381, 327

The trajectory of 9 is 23 steps in length and overlaps the trajectory of 1 (shown in blue):

9, 90, 171, 222, 210, 207, 252, 269, 310, 320, 325, 355, 414, 383, 337, 404, 372, 426, 370, 428, 344, 321, 327, 381, 327

14 is the next number of interest:

Without listing the trajectories for 10, 11, 12 and 13, it can be noted that all of their trajectories overlap that of 1. However, once we reach 14, there is a new development. The trajectory is 14, -1, 0. What happens of course is that -1 is reached and after that the trajectory is stuck on 0. See Figure 2.


Figure 2

22 and 42  are the next numbers of interest:

After this the trajectories for 15, 16, 17, 18, 19, 20 and 21 all overlap that of 1. Once 22 is reached, the same situation as with 14 prevails. The trajectory of 22 is 22, 14, -1, 0. After 22, all trajectories overlap again with that of 1 until 42 is reached and the trajectory once again plummets to zero: 42, 22, 14, -1, 0, 0.

50 is the next number of interest:

It is only when 50 is reached that we get a new trajectory. See Figure 3.


Figure 3

Once again a loop is reached but this time it is {573, 656, 609, 654, 627, 636}. The full trajectory is:

50, 75, 149, 215, 237, 291, 369, 423, 412, 393, 492, 553, 612, 573, 656, 609, 654, 627, 636, 573

62 and 75 are the next numbers of interest:

From 51 to 61, the trajectories again overlap that of 1 but at 62 it plummets to zero with a trajectory of 62, 22, 14, -1, 0, 0. From 62 to 74, the trajectory overlaps that of 1 until, at 75, the trajectory overlaps that of 50 as can be expected because 50 --> 75:

75, 149, 215, 237, 291, 369, 423, 412, 393, 492, 553, 612, 573, 656, 609, 654, 627, 636, 573

82 and 92 are the next numbers of interest:

From 76 to 81 we're back to overlapping the trajectory of 1 and at 82 we go to zero again with 82, 14, -1, 0, 0. From 83 to 91, we are back to overlapping the trajectory of 1 but at 92 we overlap the trajectory of 50 and 75 (shown in blue):

92, 169, 215, 237, 291, 369, 423, 412, 393, 492, 553, 612, 573, 656, 609, 654, 627, 636, 573

The remaining trajectories for 93 to 99 all overlap the trajectory of 1. These results for the numbers 1 to 99 can be summarised as follows:

  • 50, 75 and 92 end in the loop {573, 656, 609, 654, 627, 636}
  • 14, 22, 62 and 82 end in 0
  • all other numbers end in the loop {327, 381}
The general observation can be made that with \(k=2\) the numbers in the trajectory sequence will eventually rise because any negative odd digits (odd digits always predominate), will become positive when squared. This is not the case of course when \(k=3\) and we will look at this in a subsequent post.