Showing posts with label loop. Show all posts
Showing posts with label loop. Show all posts

Saturday, 11 July 2026

Revisiting the Divisors Algorithm

 Figure 1 shows the Divisors Algorithm that I developed early this year (link):

Figure 1

Applied to the number associated with my diurnal age today, 28223, we get the following trajectory:

28223, 169338, 4064112, 365770080, 1016028, 54865512, 7900633728, 20574567, 864131814, 165913308288, 192029292, 41478327072, 64009764, 11521757520, 13716378, 987579216, 237019011840, 243846720, 81932497920, 108150897254400, 17882092800, 17381394201600, 5486551200, 8466900, 914425200, 2032056, 28223

Figure 2 shows the trajectory. Note that the sequence returns to its starting point.


Figure 2

The vertical scale is logarithmic and the maximum value reached is impressive. Not every number enters a loop that returns it to its starting point. 28222 has a trajectory that enters a loop but it does not return to its starting point. The loop is reached at a value that is twice that of the starting point: 56444 = 2 x 28222. The trajectory is:

28222, 225776, 4515520, 252869120, 1580432, 63217280, 493885, 7902160, 98777, 790216, 25286912, 1820657664, 6321728, 112888, 1806208, 56444, 677328, 27093120, 211665, 3386640, 42333, 338664, 10837248, 780281856, 4063968, 56444

Figure 3 shows the trajectory:


Figure 3

Other numbers may or may not enter a loop but we have to call a stop somewhere. 28237 is an example of such a number where we call a halt after 99 steps. The trajectory is as shown in Figure 4 and it seems to be heading for the stars but who knows?


Figure 4

Once again, this algorithm is base-independent and so the trajectories will be identical regardless of the number base used. The trend of the trajectory for all numbers is generally upwards because of the primes \(p \rightarrow 2p+1\) but the situation will be different if we modify the rule for the primes as shown below. 

\(\text{For } p \text{ prime:}\)$$ \begin{align} &p \rightarrow 2p+1 \text{ if } p \! \bmod 4 \equiv 1 \\ &p \rightarrow \frac{p-1}{2} \text{ if }  p \bmod 4 \equiv 3 \end{align}$$
It would be interesting to investigate the trajectories using this modification. If no primes are encountered then the trajectories of course will be identical (as is the case with 28237 mentioned earlier). Here is a permalink to an implementation of this modification for the cases of:
  • primes \(p\) as above and composites \(n\) with factors counted \( \textbf{with} \) multiplicity. If \(f\) is the number of factors then:
    • if \( n \bmod f \equiv 0 \) then \(n \rightarrow n/f\)
    • if \( n \bmod f \not\equiv 0 \) then \(n \rightarrow n\times f\)
  • primes as above and composites with factors counted \textbf{without}\) multiplicity. If \(f\) is the number of factors then:
    • if \( n \bmod f \equiv 0 \) then \(n \rightarrow n/f\)
    • if \( n \bmod f \not\equiv 0 \) then \(n \rightarrow n\times f\)
  • primes as above and composites with divisors counted. If \(d\) is the number of divisors then:
    • if \( n \bmod d \equiv 0 \) then \(n \rightarrow n/d\)
    • if \( n \bmod d \not\equiv 0 \) then \(n \rightarrow n\times d\)
Here is the output for the number 28224:

=========================================
 Trajectory Analysis for N = 28224 
=========================================

1. Rule: Number of Factors (With Multiplicity)
   Highest Value: 2328480
   Trajectory Length: 15 steps
   Full Path: [28224, 282240, 23520, 211680, 2328480, 194040, 21560, 3080, 18480, 2310, 462, 1848, 308, 77, 154, 462]
   >>> Loop Detected: The sequence loops back to 462
--------------------------------------------------

2. Rule: Number of Factors (Without Multiplicity)
   Highest Value: 28224
   Trajectory Length: 9 steps
   Full Path: [28224, 9408, 3136, 1568, 784, 392, 196, 98, 49, 49]
   >>> Loop Detected: The sequence loops back to 49
--------------------------------------------------

3. Rule: Total Number of Divisors
   Highest Value: 28224
   Trajectory Length: 12 steps
   Full Path: [28224, 448, 32, 192, 2688, 84, 7, 3, 1, 2, 5, 11, 5]
   >>> Loop Detected: The sequence loops back to 5
--------------------------------------------------

Monday, 6 July 2026

Recurring Digital Invariant Variant (RDIV) Algorithm

Let's consider the following algorithm (formally called the Recurring Digital Invariant Variant or RDIV algorithm - see this link for an explanation of the name):

  • choose a number \(n\)
  • let \(k\) be the number of digits in \(n\)
  • raise each digit of \(n\) to the \(k\)-th power and add the results
  • call the new number \(n\) and repeat
Let's use \(n=14\) as an example:

  • \(14 \rightarrow 1^2 + 4^2 = 17\)
  • \(17 \rightarrow 1^2 + 7^2 = 50\)
  • \(50 \rightarrow 5^2 + 0^2 = 25\)
  • \(25 \rightarrow 2^2 + 5^2 = 29\)
  • \(29 \rightarrow 2^2 + 9^2 = 85\)
  • \(85 \rightarrow 8^2 + 5^2 = 89\)
  • \(89 \rightarrow 8^2 + 9^2 = 145\)
  • \(145 \rightarrow 1^3 + 4^3 + 5^3 = 190\)
  • \(190 \rightarrow 1^3 + 9^3 + 0^3 = 730\)
  • \(730 \rightarrow 7^3 + 3^3 + 0^3 = 370\)
  • \(370 \rightarrow 3^3 + 7^3 + 0^3 = 370\) 
370 is a narcissistic number as explained in my post Narcissistic, D-Powerfull and Friedman Numbers. The trajectory of any number under this algorithm will either end with a narcissistic number (as was the case with 14) or it will enter a loop (as is the case with 28218). The latter has the following trajectory (permalink):

==================================================
RDIV TRAJECTORY ANALYSIS FOR INPUT: 28218
==================================================
Full Trajectory Visited:

28218, 65601, 18678, 90120, 59082, 94974, 136953, 595181, 824837, 646826, 406272, 168529, 855931, 825565, 355739, 681798, 1220035, 80569, 102718, 379859, 1459029, 9660576, 6524445, 485466, 379273, 768261, 473170, 240124, 8321, 4194, 7074, 5058, 5346, 2258, 4753, 3363, 1539, 7268, 7809, 13058, 36137, 25070, 19964, 126899, 1371747, 2489202, 6896889, 16417266, 10869443, 61641187, 25966788, 86116067, 27580867, 47154531, 6683686, 5316235, 440689, 848433, 533938, 811397, 911965, 1125165, 436317, 169860, 886898, 1626673, 1665667, 2021413, 18829, 124618, 312962, 578955, 958109, 1340652, 376761, 329340, 537059, 681069 -> [loops back to 886898]

Loop Entry Point:   886898 (encountered at step 65)

Pre-period Length:  64 step(s) before entering cycle

Cycle Length:       14 distinct number(s) in the loop

Canonical Cycle:    18829, 124618, 312962, 578955, 958109, 1340652, 376761, 329340, 537059, 681069, 886898, 1626673, 1665667, 2021413

==================================================

Figure 1 shows a graph of its trajectory:

Figure 1: permalink

I've incorporated this algorithm into my daily number analysis.

Friday, 8 May 2026

Zeroless Tetranacci Numbers

In a post titled, Sequences Formed By Removing Zerosfrom January 2023,  I wrote that "It's interesting to consider what happens to a sequence if a certain rule is applied but with the stipulation that any zeros arising must be removed". In that post I looked at the zeroless Fibonacci sequence that falls into a repeating loop with a confirmed period of 912. 

The zeroless Tribonacci sequence falls into a much larger repeating loop with a confirmed period of 300,056,874. It reaches this cycle at index 208,666,297. However, it is not known whether the zeroless Tetranacci sequences cycles or not but, if it does, then \(s+p > 10^{10}\) where \(s\) and \(p\) are the starting index and period of the cycle, respectively.

 
 A371916: zeroless analog of tetranacci numbers.

The initial members are:

1, 1, 1, 1, 4, 7, 13, 25, 49, 94, 181, 349, 673, 1297, 25, 2344, 4339, 85, 6793, 13561, 24778, 45217, 9349, 9295, 88639, 1525, 1888, 11347, 13399, 28159, 54793, 17698, 11449, 11299, 95239, 135685, 253672, 495895, 98491, 983743, 183181, 176131, 1441546, 278461, 279319, 2175457

Figure 1 shows a plot of the first 100 terms:


Figure 1: permalink

Like the zeroless Fibonacci and Tribonacci sequences the ratio between successive terms of the zeroless Tetranacci sequence never approaches a limit. With no suppression of zeros, the following are the convergences:

  • Fibonacci: $\phi = \frac{1+\sqrt{5}}{2} \text{ which is }\approx 1.61803$
  • Tribonacci: the real root of $x^3 - x^2 - x - 1 = 0 \text{ which is } \approx 1.83929$
  • Tetranacci: the real root of $x^4 - x^3 - x^2 - x - 1 = 0 \text{ which is }\approx 1.92756$

Thursday, 19 March 2026

Fibonacci Forbidden Digits: A Variation

It occurred to me that it make more sense to simply declare a forbidden digit and then use any two seed numbers that do not contain this digit. As before, the digit is removed from any subsequent numbers that appear in the sequence. I put this suggestion to Gemini:

I'm thinking of a variation on the previous code whereby a forbidden digit is declared, let's so 1, but then the two seed numbers are chosen so that neither contain this digit and the digit is removed in all subsequent numbers appearing in the sequence. So the program with not accept seed numbers containing the forbidden digit so that this digit never appears. So the program will require the declaration of the forbidden digit and the two seed numbers (neither containing the forbidden digit) to get started. Apart from that, everything remains the same.

Here was Gemini's response:

This is a logical progression for the sequence. By strictly enforcing the forbidden digit at the point of entry, you completely isolate the sequence from that integer domain right from the start.

Here is the complete Python code, formatted to run in SageMathCell or a Jupyter Notebook. It includes the new validation logic to ensure the seed numbers are clean, retains the text-first output structure, and plots the graph with the exact visual specifications and headroom you established. 

Here is a SageMathCell permalink to the Gemini code (using a forbidden digit of 1 and seeds of 2 and 3. The output is:

Starting Parameters: Forbidden Digit = 1, Seeds = 2 and 3
Max Value Limit: 40000
--------------------------------------------------
Resulting Sequence (33 terms):
[2, 3, 5, 8, 3, 0, 3, 3, 6, 9, 5, 4, 9, 3, 2, 5, 7, 2, 9, 0, 9, 9, 8, 7, 5, 2, 7, 9, 6, 5, 0, 5, 5]
--------------------------------------------------
Conclusion: The sequence entered a continuous loop. 

The repeating pair that triggered the stop was: (5, 5) 


Even with these changes, the sequences behave the same as described in my earlier posts:

I prefer this variation to what I started with because the forbidden digit is truly forbidden and never makes an appearance even as a seed number.

Tuesday, 17 March 2026

There Can Be Only One 3

Let's recall the Fibonacci-like sequence from my previous two blog posts titled There Can Be Only One 1 and There Can Only Be One 2.

We start with a digit \(d\) between 0 and 9 and any integer \(s\) that does not contain \(d\). For example, 1 and 2 would be suitable. After that we begin the Fibonacci process using \(d\) and \(s\) as our seeds except that whenever a number appears containing one or more digits \(d\), they are all removed.

So far I've looked at:

  • \(d=1\) and \(s=2\) leading to a sequence that loops
  • \(d=1\) and \(s=24\) leading to a sequence that loops
  • \(d=1\) and \(s=70\) leading to a sequence that loops
  • \(d=2\) and \(s=1\) leading to sequence that is probably unbounded
  • \(d=2\) and \(s=5\) leading to a sequence that loops
Now let's look at what happens when we set \(d=3\) and \(s=1\). We very quickly end up with a sequence that loops. Here is the trajectory and Figure 1 shows the graph:

3, 1, 4, 5, 9, 14, 2, 16, 18, 4, 22, 26, 48, 74, 122, 196, 18, 214, 22


Figure 1: permalink

Once we set \(s=2\) and maintain \(d=3\), we get a longer sequence but it eventually loops. Here is the trajectory and Figure 2 shows the graph:

3, 2, 5, 7, 12, 19, 1, 20, 21, 41, 62, 10, 72, 82, 154, 26, 180, 206, 86, 292, 78, 70, 148, 218, 66, 284, 50, 4, 54, 58, 112, 170, 282, 452, 74, 526, 600, 1126, 1726, 2852, 4578, 740, 518, 1258, 1776, 4, 1780, 1784, 564, 248, 812, 1060, 1872, 292, 2164, 2456, 4620, 7076, 11696, 18772, 468, 19240, 19708, 8948, 28656, 7604, 6260, 1864, 8124, 9988, 18112, 28100, 46212, 7412, 5624, 106, 570, 676, 1246, 1922, 168, 2090, 2258, 448, 2706, 154, 2860, 14, 2874, 2888, 5762, 8650, 14412, 2062, 16474, 1856, 180


Figure 2: permalink

The sequence reaches a maximum of 46212 with the previous term being 28100. When these two numbers are added we get 74312 that collapses to 7412 and from there it struggles and eventually enters a loop.

It is only with \(d=3\) and \(s=4\) that we get a seemingly unbounded sequence (I tested to 10 million). Here is the trajectory and Figure 3 shows the graph:

3, 4, 7, 11, 18, 29, 47, 76, 12, 88, 100, 188, 288, 476, 764, 1240, 2004, 244, 2248, 2492, 4740, 722, 5462, 6184, 11646, 1780, 1426, 206, 162, 68, 20, 88, 108, 196, 4, 200, 204, 404, 608, 1012, 1620, 262, 1882, 2144, 4026, 6170, 10196, 1666, 11862, 1528, 190, 1718, 1908, 626, 254, 880, 114, 994, 1108, 2102, 210, 212, 422, 64, 486, 550, 106, 656, 762, 1418, 2180, 598, 2778, 76, 2854, 290, 144, 44, 188, 22, 210, 22, 22, 44, 66, 110, 176, 286, 462, 748, 1210, 1958, 168, 2126, 2294, 4420, 6714, 1114, 7828, 8942, 16770, 25712


Figure 3: permalink

So that will probably do it for now. We've seen that it was only with \(d=1\) that we inevitably end up with sequences that loop for values of \(s<100\). For \(d>1\), the sequences can loop or increase without bound depending on the values of \(s\).

Monday, 16 March 2026

There Can Be Only One 2

Let's recall the Fibonacci-like sequence from my previous blog post titled There Can Be Only One 1.

We start with a digit \(d\) between 0 and 9 and any integer \(s\) that does not contain \(d\). For example, 1 and would be suitable. After that we begin the Fibonacci process using \(d\) and \(s\) as our seeds except that whenever a number appears containing one or more digits \(d\), they are all removed. 

In my previous post, I looked at three scenarios:

  • \(d=1\) and \(s=2\)
  • \(d=1\) and \(s=24\)
  • \(d=1\) and \(s=70\)
A major change occurs when we consider \(d=2\) as our "forbidden digit". Suddenly the 100 barrier can be breached as can be seen in Figure 1 where the sequence for \(d=2\) and \(s=1\) is depicted. Here the resulting sequence does not loop but exceeds the upper bound of 40000 that was set.


Figure 1: permalink

The sequence progresses like this:

[2, 1, 3, 4, 7, 11, 18, 9, 7, 16, 3, 19, 0, 19, 19, 38, 57, 95, 15, 110, 15, 15, 30, 45, 75, 10, 85, 95, 180, 75, 55, 130, 185, 315, 500, 815, 1315, 130, 1445, 1575, 300, 1875, 175, 50, 5, 55, 60, 115, 175, 90, 65, 155, 0, 155, 155, 310, ...

We can see that 155 + 155 = 310 jumps over the 200 barrier and from there it becomes seemingly unbounded (I tested up to ten million).

Not all values of \(s\) lead to unbounded sequences. For example, \(s=5\) leads quickly to a loop (see Figure 2): 

Starting Parameters: Forbidden Digit = 2, Second Number = 5

Max Value Limit: 40000
--------------------------------------------------
Resulting Sequence (17 terms):
[2, 5, 7, 1, 8, 9, 17, 6, 3, 9, 1, 10, 11, 1, 1, 0, 1]
--------------------------------------------------
Conclusion: The sequence entered a continuous loop.
The repeating pair that triggered the stop was: (0, 1)

Figure 2: permalink

Sequences are unbounded for \(s=1, 3, 4\) but loop for \(s=5, 6, 7, 8, 9, 10\) before becoming unbounded again for \(s=11\).

Tuesday, 27 January 2026

Number's Factors to Sequence Algorithm 1

Suppose we take any positive integer \(n \gt 1\) and apply the following rules to it:
  • if prime, double it and add 1: \(n \rightarrow 2n+1\)
  • if composite, determine its number of factors \(f\) counted with multiplicity
  • if \( n \pmod f \equiv 0\) then \(n \rightarrow \dfrac{n}{f} \)
  • if \( n \pmod f \not\equiv 0 \) then \(n \rightarrow n \times f\)
Keep repeating this process until a loop is reached or call a stop after a fixed number of iterations. Let's use 28058 as an example. The sequence generated is 28058, 14029, 28059, 9353, 18706, 56118, 224472, 37412, 9353 and the details are as follows:

  • \(28058 = 2 \times 14029\) and there are two factors
    2 divides 28056 to give 14209

  • \(14029\) is prime
    multiplying by 2 and adding 1 we get 28059

  • \(28059 = 3 \times 47 \times 199\) and there are three factors
    3 divides 28059 to give 9353

  • \(9353 = 47 \times 199\) and there are two factors but 2 doesn't divide 9353
    multiplying by 2 gives 18706

  • \(18706 = 2 \times 47 \times 199\) and there are three factors but 3 doesn't divide 18706
    multiplying by 3 gives 56118

  • \(56118 = 2 \times 3 \times 47 \times 199\) and there are four factors but 4 doesn't divide 56118
    multiplying by 4 gives 224472

  • \(224472 = 2^3 \times 3 \times 47 \times 199\) and there are six factors (with multiplicity)
    6 divides 224472 to give 37412

  • \(37412 = 2^2 \times 47 \times 199\) and there are four factors (with multiplicity)
    4 divides 37412 to give 9353

  • \(9353\) occurred earlier in the sequence and so we have a loop
Figure 1 shows the trajectory.


Figure 1

Some numbers return to their starting points. 27056 is one such number. It's sequence is 28056, 4676, 1169, 2338, 7014, 28056. What appeals to me about this sequence is that it is \( \textbf{base independent}\). Here is permalink to generate the sequence of any number entered into it.

An investigation into what numbers produced sequences of record lengths returned the following number in the range up to one million:

2, 3, 6, 8, 13, 19, 38, 57, 76, 304, 1024, 1579, 2401, 3584, 10331, 12119, 12500, 15379, 24251, 30689, 48661, 57122, 66749, 116603, 155201, 232801, 465602, 698403, 931204

The final number in the list (931204) produces a sequence of length 155. Here are the full details for all the numbers in the list (permalink):
2 --> 11
3 --> 15
6 --> 16
8 --> 18
13 --> 20
19 --> 24
38 --> 25
57 --> 27
76 --> 29
304 --> 32
1024 --> 34
1579 --> 40
2401 --> 43
3584 --> 49
10331 --> 51
12119 --> 53
12500 --> 61
15379 --> 64
24251 --> 65
30689 --> 66
48661 --> 69
57122 --> 92
66749 --> 105
116603 --> 145
155201 --> 146
232801 --> 150
465602 --> 151
698403 --> 153
931204 --> 155

The sequence for 931204 is as follows: 

931204, 2793612, 698403, 1396806, 465602, 232801, 465603, 931206, 310402, 155201, 310403, 1241612, 7449672, 931209, 4656045, 27936270, 223490160, 2458391760, 204865980, 1843793820, 167617620, 16761762, 134094096, 1475035056, 122919588, 13657732, 95604124, 764832992, 69530272, 695302720, 8343632640, 556242176, 7231148288, 516510592, 6198127104, 92971906560, 5468935680, 341808480, 28484040, 256356360, 2819919960, 234993330, 26110370, 182772590, 1462180720, 132925520, 13292552, 1661569, 8307845, 49847070, 398776560, 4386542160, 365545180, 3289906620, 299082420, 29908242, 239265936, 2631925296, 219327108, 1973943972, 179449452, 1794494520, 149541210, 16615690, 2373670, 14242020, 113936160, 1253297760, 104441480, 939973320, 85452120, 8545212, 68361696, 751978656, 62664888, 563983992, 51271272, 512712720, 42726060, 4747340, 33231380, 265851040, 2924361440, 35092337280, 2339489152, 179960704, 2159528448, 32392926720, 550679754240, 30593319680, 458899795200, 26994105600, 1687131600, 140594300, 1265348700, 115031700, 11503170, 92025360, 1012278960, 84356580, 759209220, 69019020, 6901902, 55215216, 607367376, 50613948, 5623772, 803396, 4820376, 602547, 3012735, 18076410, 144611280, 13146480, 1314648, 164331, 821655, 4929930, 39439440, 433833840, 36152820, 4016980, 28118860, 224950880, 20450080, 2045008, 255626, 1278130, 7668780, 61350240, 674852640, 56237720, 506139480, 46012680, 4601268, 36810144, 404911584, 33742632, 303683688, 27607608, 276076080, 23006340, 2556260, 365180, 2191080, 273885, 54777, 219108, 36518, 146072, 876432, 109554, 547770, 91295, 365180

The range of values in this sequence is extreme, ranging from a minimum of 36,518 to a maximum of 550,679,754,240. Figure 2 shows the trajectory with a log scale being necessary for the \(y\) axis.


Figure 2

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

Monday, 19 May 2025

The 17x + 1 Map Revisited

It's been a while, over seven years in fact since I last mentioned the 17\(x\) + 1 map in an eponymous post in March of 2018. As I explained back then:
Having recently written yet again about the Collatz trajectory, I was pleasantly surprised today to come upon a more generalised version of it. It goes by the name of the P\(x\) + 1 map of which the Collatz trajectory is a specific example in which P = 3. The P\(x\) + 1 trajectory or map is an algorithm that states: 

If \(x\) is divisible by any prime < P then divide out these primes one at a time starting with the smallest; otherwise multiply \(x\) by P and add 1.

My number for today is 25186 and it appears as an entry in OEIS A057534 that states:
  • a(\(n\) +1) = a(\(n\))/2 if 2 | a(\(n\))
  • a(\(n\)+1) = a(\(n\)) / 3 if 3 | a(\(n\))
  • a(\(n\)+1) = a(\(n\)) / 5 if 5 | a(\(n\))
  • a(\(n\)+1) = a(\(n\)) / 7 if 7 | a(\(n\))
  • a(\(n\)+1) = a(\(n\)) / 11 if 11 | a(\(n\))
  • a(\(n\)+1) = a(\(n\)) / 13 if 13 | a(\(n\))
  • else a(\(n\)+1) = 17 x a(\(n\)) + 1
This is a particular example of the P\(x\) + 1 map in which P = 17 and this generates a sequence, part of which is shown below:

61, 1038, 519, 173, 2942, 1471, 25008, 12504, 6252, 3126, 1563, 521, 8858, 4429, 75294, 37647, 12549, 4183, 71112, 35556, 17778, 8889, 2963, 50372, 25186, 12593, 1799, 257, 4370, 2185, 437, 7430, 3715, 743, 12632, 6316, 3158, 1579, 26844, 13422, ...

Well, that was then, and so let's write out the above sequence in full because it is finite and loops. Here are the 84 terms (or 83 steps) with 61 added at the end to show the return to source:

61, 1038, 519, 173, 2942, 1471, 25008, 12504, 6252, 3126, 1563, 521, 8858, 4429, 75294, 37647, 12549, 4183, 71112, 35556, 17778, 8889, 2963, 50372, 25186, 12593, 1799, 257, 4370, 2185, 437, 7430, 3715, 743, 12632, 6316, 3158, 1579, 26844, 13422, 6711, 2237, 38030, 19015, 3803, 64652, 32326, 16163, 2309, 39254, 19627, 333660, 166830, 83415, 27805, 5561, 94538, 47269, 803574, 401787, 133929, 44643, 14881, 252978, 126489, 42163, 3833, 65162, 32581, 553878, 276939, 92313, 30771, 10257, 3419, 263, 4472, 2236, 1118, 559, 43, 732, 366, 183, 61

Why am I discussing this sequence again today? Well, the number associated with my diurnal age today (\( \textbf{27805} \)) is a member of this sequence. We can see this more clearly if we arrange the terms in ascending order.

43, 61, 173, 183, 257, 263, 366, 437, 519, 521, 559, 732, 743, 1038, 1118, 1471, 1563, 1579, 1799, 2185, 2236, 2237, 2309, 2942, 2963, 3126, 3158, 3419, 3715, 3803, 3833, 4183, 4370, 4429, 4472, 5561, 6252, 6316, 6711, 7430, 8858, 8889, 10257, 12504, 12549, 12593, 12632, 13422, 14881, 16163, 17778, 19015, 19627, 25008, 25186, 26844, \( \textbf{27805} \), 30771, 32326, 32581, 35556, 37647, 38030, 39254, 42163, 44643, 47269, 50372, 64652, 65162, 71112, 75294, 83415, 92313, 94538, 126489, 133929, 166830, 252978, 276939, 333660, 401787, 553878, 803574

We can see that after 25186, the number that prompted my original post, there has only been one other member (26844) until today. If we start with 27805 then the sequence returns to this same number after 85 iterations (permalink):

27805, 5561, 94538, 47269, 803574, 401787, 133929, 44643, 14881, 252978, 126489, 42163, 3833, 65162, 32581, 553878, 276939, 92313, 30771, 10257, 3419, 263, 4472, 2236, 1118, 559, 43, 732, 366, 183, 61, 1038, 519, 173, 2942, 1471, 25008, 12504, 6252, 3126, 1563, 521, 8858, 4429, 75294, 37647, 12549, 4183, 71112, 35556, 17778, 8889, 2963, 50372, 25186, 12593, 1799, 257, 4370, 2185, 437, 7430, 3715, 743, 12632, 6316, 3158, 1579, 26844, 13422, 6711, 2237, 38030, 19015, 3803, 64652, 32326, 16163, 2309, 39254, 19627, 333660, 166830, 83415, 27805

Figure 1 shows a plot of these values using a logarithmic scale:


Figure 1: permalink

Now this sequence of length 84 or 83 steps is not the longest by far, In fact as the numbers get larger then the lengths of the record breaking sequence lengths also increases steadily. Table 1 shows these record step lengths for numbers up to 40000 as well as indicating whether the sequences end up looping or reaching 1.

\( \textbf{17x + 1} \)


Table 1: record step lengths of 17\(x\) + 1
permalink

It must be said the generation of this table timed out using SageMathCell and needed to be completed in my Jupyter notebook. While we are on the topic, we should look at the record step lengths for primes 3, 5, 7, 11 and 13 as well. Let's start with 13\(x\) + 1. The numbers with record breaking steps are as follows (with Table 2 showing more detail):

1, 2, 4, 8, 13, 26, 41, 61, 122, 197, 271, 529, 661, 1322, 1607, 3214, 4337, 4597, 4981, 7663, 15326, 27859
\( \textbf{13x + 1} \)


Table 2: record step lengths of 13\(x\) + 1
permalink

The numbers with record breaking steps for P11 + 1 are as follows (with Table 3 showing more detail):

1, 2, 4, 8, 11, 22, 23, 46, 92, 151, 247, 407, 653, 883, 977, 1313, 1703, 2477, 4954, 6847, 12449, 14471, 19013, 21527, 22627, 39281

\( \textbf{11x + 1} \)

Table 3: record steps lengths of 11\(x\) + 1
permalink

The numbers with record steps for P7 + 1 are (with Table 4 showing more details):

1, 3, 6, 7, 11, 19, 31, 49, 53, 106, 121, 163, 283, 343, 403, 806, 1471, 1681, 1919, 3133, 4243, 4849, 8659, 11683, 12373, 24746, 30301, 35803

\( \textbf{7x + 1} \)


Table 4: record step lengths of 7\(x\) + 1
permalink

The numbers with record steps for P5+1 are (with Table 5 showing more details):

1, 2, 4, 5, 10, 20, 23, 46, 47, 85, 95, 190, 380, 383, 766, 919, 1655, 2117, 3575, 6097, 6503, 10463, 12053, 24106, 28927, 39053

\( \textbf{5x + 1} \)

Table 5: record steps lengths of 5\(x\) + 1
permalink

The numbers with record lengths for P3 + 1 (with Table 6 showing more details) are:

1, 3, 6, 7, 9, 18, 25, 27, 54, 73, 97, 129, 171, 231, 313, 327, 649, 703, 871, 1161, 2223, 2463, 2919, 3711, 6171, 10971, 13255, 17647, 23529, 26623, 34239, 35655

\( \textbf{3x + 1} \)

Table 6: record lengths for 3\(x\) + 1
permalink

If we collect all the numbers from all the sequences above then we have a list of all the numbers that reach a record number of steps under the P\(x\) + 1 mappings where \(x\) = 3, 5, 7, 11, 13 and 17. Here is the list in the range from 1 to 40,000:

1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 18, 19, 20, 22, 23, 25, 26, 27, 31, 41, 43, 46, 47, 49, 53, 54, 61, 73, 85, 92, 95, 97, 106, 121, 122, 129, 151, 163, 171, 173, 183, 190, 197, 231, 247, 257, 263, 271, 283, 313, 327, 343, 366, 380, 383, 403, 407, 437, 519, 521, 529, 559, 649, 653, 661, 703, 732, 743, 766, 806, 871, 883, 919, 977, 1038, 1118, 1161, 1313, 1322, 1471, 1563, 1579, 1607, 1655, 1681, 1703, 1799, 1919, 2117, 2185, 2223, 2236, 2237, 2309, 2463, 2477, 2919, 2942, 2963, 3126, 3133, 3158, 3214, 3419, 3575, 3711, 3715, 3803, 3833, 4183, 4243, 4337, 4370, 4429, 4472, 4597, 4849, 4954, 4981, 5561, 6097, 6171, 6252, 6316, 6503, 6711, 6847, 7430, 7663, 8659, 8858, 8889, 10257, 10463, 10971, 11683, 12053, 12373, 12449, 12504, 12549, 12593, 12632, 13255, 13422, 14471, 14881, 15326, 16163, 17647, 17778, 19013, 19015, 19627, 21527, 22627, 23529, 24106, 24746, 25008, 25186, 26623, 26844, 27805, 27859, 28927, 30301, 30771, 32326, 32581, 34239, 35556, 35655, 35803, 37647, 38030, 39053, 39254, 39281

Wednesday, 27 November 2024

Prime and Non-Prime Digit Sequence

I've posted extensively about the trajectories formed by repeatedly adding the sum of the odd digits of a number to the number itself while subtracting the sum of the even digits, or vice versa. My most recent post was on this topic was titled Revisiting Odds And Evens. Instead of dealing with odd and even digits, trajectories involving prime and non-prime digit sums can be considered. The prime digits are 2, 3, 5 and 7 while the non-prime digits are 0, 1, 4, 6, 7 and 9.

For example, the number associated with my diurnal age today is 27632 and it has the following trajectory of 3 steps under the prime and non-prime algorithm (permalink):

27632 --> 27640 --> 27639 --> 27636 --> 27636

The trajectory terminates when the number has a sum of primes and sum of non-primes that are equal, here 2 + 7 + 3 = 6 + 6. Numbers such as these are NOT listed in the OEIS but there is a listing for prime numbers with this property. There are 137 such primes in the range up to 40,000.


A371352
: prime numbers such that the sum of their prime digits is equal to the sum of their nonprime digits.

The sequence begins (permalink):

167, 211, 541, 617, 761, 853, 1021, 1201, 1423, 1559, 1607, 1973, 2011, 2143, 2341, 2383, 2833, 3467, 3719, 3823, 3917, 4051, 4231, 4637, 4673, 5261, 5443, 5519, 5591, 6473, 6521, 6701, 7193, 7643, 7687, 7867, 8053, 8233, 8677, 9137, 9173, 9371, 9551, 10067, 10243, 10559, 10607, 10739, 10937, 10973, 11471, 11783, 12043, 12263, 12539, 12953, 13187, 13259, 13709, 13781, 13907, 14779, 14797, 15329, 15361, 15581, 15923, 16007, 16223, 17093, 17183, 17497, 17749, 17903, 18371, 18713, 18731, 19037, 19073, 19477, 20011, 20101, 20143, 20341, 20431, 21001, 22613, 23041, 23159, 24103, 25391, 25463, 25601, 25643, 25867, 25913, 25931, 26321, 26501, 28657, 29153, 29531, 30197, 30241, 30467, 30971, 31079, 31259, 31817, 31907, 32083, 32159, 32261, 32401, 32443, 32621, 32803, 33479, 33749, 34607, 34739, 35129, 35291, 36151, 37019, 37181, 37493, 37811, 37879, 37897, 37987, 38711, 38977, 39107, 39251, 39521, 39877

Many number trajectories will end in what I call an "attractor", using my Odds and Evens terminology. This is a number whose sums of prime and non-prime digits are equal. For completeness, here is a list of all the 446 NUMBERS (prime or composite) greater than 27630 and less than 40000 with the property that the sum of their prime digits equals the sum of their non-prime digits (permalink):

27636, 27658, 27663, 27685, 27788, 27801, 27810, 27834, 27843, 27856, 27865, 27878, 27887, 27900, 28017, 28033, 28071, 28107, 28125, 28152, 28170, 28215, 28222, 28251, 28303, 28330, 28347, 28374, 28437, 28455, 28473, 28512, 28521, 28545, 28554, 28567, 28576, 28657, 28675, 28701, 28710, 28734, 28743, 28756, 28765, 28778, 28787, 28877, 29007, 29025, 29052, 29070, 29135, 29153, 29205, 29223, 29232, 29250, 29315, 29322, 29351, 29502, 29513, 29520, 29531, 29700, 30036, 30058, 30063, 30085, 30111, 30124, 30142, 30179, 30197, 30214, 30238, 30241, 30283, 30306, 30328, 30339, 30360, 30382, 30393, 30412, 30421, 30445, 30454, 30467, 30476, 30508, 30544, 30580, 30603, 30630, 30647, 30674, 30719, 30746, 30764, 30791, 30805, 30823, 30832, 30850, 30917, 30933, 30971, 31011, 31024, 31042, 31079, 31097, 31101, 31110, 31134, 31143, 31156, 31165, 31178, 31187, 31204, 31226, 31240, 31259, 31262, 31295, 31314, 31338, 31341, 31383, 31402, 31413, 31420, 31431, 31516, 31529, 31561, 31592, 31615, 31622, 31651, 31709, 31718, 31781, 31790, 31817, 31833, 31871, 31907, 31925, 31952, 31970, 32014, 32038, 32041, 32083, 32104, 32126, 32140, 32159, 32162, 32195, 32216, 32229, 32261, 32292, 32308, 32344, 32380, 32401, 32410, 32434, 32443, 32456, 32465, 32478, 32487, 32519, 32546, 32564, 32591, 32612, 32621, 32645, 32654, 32667, 32676, 32748, 32766, 32784, 32803, 32830, 32847, 32874, 32915, 32922, 32951, 33006, 33028, 33039, 33060, 33082, 33093, 33114, 33138, 33141, 33183, 33208, 33244, 33280, 33309, 33318, 33381, 33390, 33411, 33424, 33442, 33479, 33497, 33600, 33749, 33794, 33802, 33813, 33820, 33831, 33903, 33930, 33947, 33974, 34012, 34021, 34045, 34054, 34067, 34076, 34102, 34113, 34120, 34131, 34201, 34210, 34234, 34243, 34256, 34265, 34278, 34287, 34311, 34324, 34342, 34379, 34397, 34405, 34423, 34432, 34450, 34504, 34526, 34540, 34559, 34562, 34595, 34607, 34625, 34652, 34670, 34706, 34728, 34739, 34760, 34782, 34793, 34827, 34872, 34937, 34955, 34973, 35008, 35044, 35080, 35116, 35129, 35161, 35192, 35219, 35246, 35264, 35291, 35404, 35426, 35440, 35459, 35462, 35495, 35549, 35594, 35611, 35624, 35642, 35679, 35697, 35769, 35796, 35800, 35912, 35921, 35945, 35954, 35967, 35976, 36003, 36030, 36047, 36074, 36115, 36122, 36151, 36212, 36221, 36245, 36254, 36267, 36276, 36300, 36407, 36425, 36452, 36470, 36511, 36524, 36542, 36579, 36597, 36627, 36672, 36704, 36726, 36740, 36759, 36762, 36795, 36957, 36975, 37019, 37046, 37064, 37091, 37109, 37118, 37181, 37190, 37248, 37266, 37284, 37349, 37394, 37406, 37428, 37439, 37460, 37482, 37493, 37569, 37596, 37604, 37626, 37640, 37659, 37662, 37695, 37789, 37798, 37811, 37824, 37842, 37879, 37897, 37901, 37910, 37934, 37943, 37956, 37965, 37978, 37987, 38005, 38023, 38032, 38050, 38117, 38133, 38171, 38203, 38230, 38247, 38274, 38302, 38313, 38320, 38331, 38427, 38472, 38500, 38711, 38724, 38742, 38779, 38797, 38977, 39017, 39033, 39071, 39107, 39125, 39152, 39170, 39215, 39222, 39251, 39303, 39330, 39347, 39374, 39437, 39455, 39473, 39512, 39521, 39545, 39554, 39567, 39576, 39657, 39675, 39701, 39710, 39734, 39743, 39756, 39765, 39778, 39787, 39877

Also for completeness, here is a list of all the numbers greater than 27630 and less than 40000 with the property they map back to themselves after two or more repetitions of the prime / non-prime algorithm. In other words, they are "vorticals" each belonging to a "vortex" to use my Odds and Evens nomenclature.

27675, 27684, 27690, 27823, 27829, 27837, 27848, 27855, 27866, 27873, 27884, 27922, 27926, 27933, 27939, 27954, 27955, 27964, 27965, 27972, 27981, 28027, 28030, 28272, 28273, 28277, 28279, 28282, 28287, 28352, 28355, 28356, 28362, 28532, 28536, 28553, 28560, 28723, 28729, 28737, 28748, 28755, 28766, 28773, 28784, 29272, 29276, 29372, 29373, 29377, 29379, 29382, 29387, 29507, 29511, 29512, 29552, 29553, 29557, 29559, 29566, 29567, 29570, 29575, 29580, 29585, 29722, 29726, 29733, 29739, 29754, 29755, 29764, 29765, 29772, 29781, 30003, 30009, 30012, 30016, 30075, 30084, 30090, 30102, 30106, 30135, 30138, 30145, 30148, 30259, 30260, 30277, 30286, 30296, 30342, 30346, 30378, 30383, 30384, 30387, 30391, 30392, 30432, 30436, 30453, 30460, 30562, 30566, 30652, 30655, 30656, 30662, 30782, 30786, 30795, 30801, 30872, 30876, 30927, 30930, 31002, 31006, 31035, 31038, 31045, 31048, 31123, 31129, 31137, 31148, 31155, 31166, 31173, 31184, 31213, 31219, 31276, 31281, 31359, 31360, 31377, 31386, 31396, 31407, 31411, 31412, 31452, 31453, 31457, 31459, 31466, 31467, 31470, 31475, 31480, 31485, 31543, 31549, 31579, 31584, 31672, 31673, 31677, 31679, 31682, 31687, 31763, 31769, 31827, 31830, 32059, 32060, 32077, 32086, 32096, 32113, 32119, 32176, 32181, 32243, 32249, 32279, 32284, 32362, 32366, 32423, 32429, 32437, 32448, 32455, 32466, 32473, 32484, 32582, 32586, 32632, 32636, 32653, 32660, 32793, 32797, 32799, 32806, 32807, 32811, 32852, 32855, 32856, 32862, 32972, 32973, 32977, 32979, 32982, 32987, 33042, 33046, 33078, 33083, 33084, 33087, 33091, 33092, 33159, 33160, 33177, 33186, 33196, 33262, 33266, 33363, 33369, 33402, 33406, 33435, 33438, 33445, 33448, 33583, 33589, 33592, 33596, 33622, 33626, 33633, 33639, 33654, 33655, 33664, 33665, 33672, 33681, 33807, 33811, 33812, 33852, 33853, 33857, 33859, 33866, 33867, 33870, 33875, 33880, 33885, 33952, 33955, 33956, 33962, 34032, 34036, 34053, 34060, 34107, 34111, 34112, 34152, 34153, 34157, 34159, 34166, 34167, 34170, 34175, 34180, 34185, 34223, 34229, 34237, 34248, 34255, 34266, 34273, 34284, 34302, 34306, 34335, 34338, 34345, 34348, 34472, 34476, 34513, 34519, 34576, 34581, 34742, 34746, 34778, 34783, 34784, 34787, 34791, 34792, 35062, 35066, 35143, 35149, 35179, 35184, 35282, 35286, 35383, 35389, 35392, 35396, 35413, 35419, 35476, 35481, 35602, 35606, 35635, 35638, 35645, 35648, 35822, 35826, 35833, 35839, 35854, 35855, 35864, 35865, 35872, 35881, 35932, 35936, 35953, 35960, 36052, 36055, 36056, 36062, 36172, 36173, 36177, 36179, 36182, 36187, 36232, 36236, 36253, 36260, 36322, 36326, 36333, 36339, 36354, 36355, 36364, 36365, 36372, 36381, 36502, 36506, 36535, 36538, 36545, 36548, 36713, 36719, 36776, 36781, 37082, 37086, 37163, 37169, 37293, 37299, 37442, 37446, 37478, 37483, 37484, 37487, 37491, 37492, 37613, 37619, 37676, 37681, 37802, 37806, 37835, 37838, 37845, 37848, 37923, 37929, 37937, 37948, 37955, 37966, 37973, 37984, 38072, 38076, 38127, 38130, 38252, 38255, 38256, 38262, 38307, 38311, 38312, 38352, 38353, 38357, 38359, 38366, 38367, 38370, 38375, 38380, 38385, 38522, 38526, 38533, 38539, 38554, 38555, 38564, 38565, 38572, 38581, 38702, 38706, 38735, 38738, 38745, 38748, 39027, 39030, 39272, 39273, 39277, 39279, 39282, 39287, 39352, 39355, 39356, 39362, 39532, 39536, 39553, 39560, 39723, 39729, 39737, 39748, 39755, 39766, 39773, 39784

Take for example, the first member of the above series of numbers:

27675 --> 27690 --> 27684 --> 27675

Here (27675, 27690, 27684) forms a vortex while the individual members (27675, 27690 and 27684) are vorticals. If a number is not an attractor or a vortical then it will captured either by an attractor or a vortex. For example, 27676 is captured by the vortex just mentioned:

27676 --> 27680 --> 27675 --> 27690 --> 27684 --> 27675

On the other hand, 27659 is captured by the attractor 27658:

27659 --> 27658 --> 27658

I've now included in my multipurpose algorithm the trajectory of a number under the prime and non-prime algorithm.