Showing posts with label Tribonacci. Show all posts
Showing posts with label Tribonacci. Show all posts

Thursday, 25 June 2026

Reverse Engineering Part 2

In my previous post Reverse Engineering Part 1, I had specified to Gemini that I wanted \(p + q + r \) to be the minimum possible within the specifications that each of these coefficients were to be between -9 and -9 inclusive. I was thinking in terms of the sum getting as close to zero as possible forgetting that the minimum possible sum would be -27. That's why I was getting coefficients in the output that were all negative. The algorithm was doing what I'd asked of it! What I should have instructed Gemini to do was to take the absolute value of \(p+q+r\). So to summarise, our starting point is:$$ \begin{align} &\text{a}(n)=p \times \text{a}(n-1)+q \times \text{a}(n-2) + r \times \text{a}(n-2)\\ &\text{with } -9 \leq p,q,r \leq 9, 0 \leq \text{a}(2), \text{a}(1),\text{a}(0) \leq 9 \\ &\text{and } |p+q+r| \text{ as close to zero as possible} \end{align}$$Having gotten Gemini to modify the algorithm, the result for 28206 becomes :$$ \begin{align} &\text{a}(n)=5 \times \text{a}(n-1)-7 \times \text{a}(n-2) + 2 \times \text{a}(n-2)\\ &a(0) = 2, a(1) = 2, a(2) = 6\end{align}$$The full details are (permalink):

Target Number: 28206
------------------------------
Constants found: p = 5, q = -7, r = 2
Constraint check: Minimum |p + q + r| = 0 (Actual Sum = 0)
Seed numbers:    a(0) = 2, a(1) = 2, a(2) = 6
------------------------------
Sequence progression:
  a(0) = 2
  a(1) = 2
  a(2) = 6
  a(3) = 20
  a(4) = 62
  a(5) = 182
  a(6) = 516
  a(7) = 1430
  a(8) = 3902
  a(9) = 10532
  a(10) = 28206
------------------------------
Comma-separated sequence:
2, 2, 6, 20, 62, 182, 516, 1430, 3902, 10532, 28206

This is a longer sequence than previously (2, 4, 2, -48, 408, -3390, 28206) but it has no negative members and is free of the wild gyrations that characterise the former. Similarly for 28207, we have (permalink):$$ \begin{align} &\text{a}(n)=5 \times \text{a}(n-1)+4 \times \text{a}(n-2) -8 \times \text{a}(n-2)\\ &a(0) = 1, a(1) = 1, a(2) = 7\end{align}$$The full results are (permalink):

Target Number: 28207
------------------------------
Constants found: p = 5, q = 4, r = -8
Constraint check: Minimum |p + q + r| = 1 (Actual Sum = 1)
Seed numbers:    a(0) = 1, a(1) = 1, a(2) = 7
------------------------------
Sequence progression:
  a(0) = 1
  a(1) = 1
  a(2) = 7
  a(3) = 31
  a(4) = 175
  a(5) = 943
  a(6) = 5167
  a(7) = 28207
------------------------------
Comma-separated sequence:
1, 1, 7, 31, 175, 943, 5167, 28207

This is shorter than the previously calculated sequence (3, 5, 1, -73, 243, -323, -311, 2207, -3445, -3595, 27729, -51001, -16797, 304365, -658279, 28207) and again it has no negative members and is free of the wild gyrations that characterise the former. So, a lesson learned. I've modified my daily number analysis algorithm accordingly. 

Wednesday, 24 June 2026

Reverse Engineering Part 1

I have a sub-program in my daily number analysis program that will work backwards to find Fibonacci seed numbers that will generate a sequence of terms that leads to my daily number. For example, today I am 28206 days old, and my sub-program generates the following output:

Fibonacci Sequence: Smallest Starting Pair for Target 28206
Starting numbers: a = 126, b = 118
Sequence length to target: 13
Full sequence: [126, 118, 244, 362, 606, 968, 1574, 2542, 4116, 6658, 10774, 17432, 28206]

This can be expressed as:$$ \begin{align} \text{a}(n)=\text{a}(n-1) + \text{a}(n-2)  \\ \text{where } \text{a}(0)=126 \text{ and } \text{a}(1)=118 \end{align}$$These large initial values disturbed me and I wondered if the addition of coefficients \(p\) and \(q\) might reduce the size of the seed numbers required.

I asked Gemini the following:

I would like you to write a program in SageMath that will accept any positive integer \(n > 9\) as input and work backwards to find two seed numbers \( \text{a}(0) \text{ and } \text{a}(1)\) that, combined with constants \(p\) and \(q\), will lead to \(n\) via a Fibonacci-like sequence generated by \( \text{a}(n) = p \times \text{a}(n-1) + q \times \text{a}(n-2)\). The restrictions are that the seed numbers must be between 1 and 9 and the constants \(p\) and \(q\) must also be between -9 and 9.  In the case of more than one combination of constants and seed numbers being found, the criterion is that \(p + q\) should be the minimum possible. The default value for n can be taken as 28206. The program should run in SageMathCell and a Jupyter notebook. The output should show the sequence as it progresses from its starting seed numbers to the final number n. The members of the sequence should also be displayed as comma-separated values.

Unfortunately these restraints proved too restrictive and so I turned to Tribonacci numbers looking for three seed numbers, each between 0 and 9, and three constants \(p, q, r\), each lying between -9 and 9 so that:$$\text{a}(n) = p \times \text{a}(n-1) + q \times \text{a}(n-2) + r \times \text{a}(n-3) $$This proved more productive with Gemini creating the program and producing the following output (permalink):

Target Number: 28206
------------------------------
Constants found: p = -9, q = -6, r = -3
Constraint check: Minimum p + q + r = -18
Seed numbers:    a(0) = 2, a(1) = 4, a(2) = 2
------------------------------
Sequence progression:
  a(0) = 2
  a(1) = 4
  a(2) = 2
  a(3) = -48
  a(4) = 408
  a(5) = -3390
  a(6) = 28206
------------------------------
Comma-separated sequence:
2, 4, 2, -48, 408, -3390, 28206

For me, this is a more satisfactory output with the recursion looking like this: $$ \begin{align} &\text{a}(n) = -9 \times \text{a}(n-1) -6 \times \text{a}(n-2) -3 \times \text{a}(n-3) \\ &\text{with } \text{a}(0)=2, \text{a}(1)=4, \text{a}(2)=2 \end{align}$$What we have here is an homogenous linear recurrence relation of order 3 with coefficients and boundary conditions (seed values) as shown. The sequence is defined by two tuples: the coefficient tuple C and initial value tuple I and written as (C, I). In the example just shown, the representation would be:$$((-9, -6, -3), (2,4,2))$$Let's look at the next number 28207 characterised by ((-4, -9, -8), (3, 5, 1)):

Target Number for Reverse Tribonacci: 28207
------------------------------
Constants found: p = -4, q = -9, r = -8
Constraint check: Minimum p + q + r = -21
Seed numbers:    a(0) = 3, a(1) = 5, a(2) = 1
------------------------------
Sequence progression:
  a(0) = 3
  a(1) = 5
  a(2) = 1
  a(3) = -73
  a(4) = 243
  a(5) = -323
  a(6) = -311
  a(7) = 2207
  a(8) = -3445
  a(9) = -3595
  a(10) = 27729
  a(11) = -51001
  a(12) = -16797
  a(13) = 304365
  a(14) = -658279
  a(15) = 28207
------------------------------
Comma-separated sequence:
3, 5, 1, -73, 243, -323, -311, 2207, -3445, -3595, 27729, -51001, -16797, 304365, -658279, 28207

Figure 1 shows the trajectory of the sequence which begins to fluctuate wildly but the negative by negative multiplication quickly homes in on the target number (28207).

Figure 1

I've now incorporated this information into my daily number analysis.

Sunday, 7 June 2026

Self-Fibonacci

Here is an interesting sequence generated by a hidden connection to Fibonacci based on the letter-number association shown in Table 1:


Table 1: source

The sequence is OEIS A129938:


A129938
: "Self-Fibonacci"; a(n) is the sum of the last nine terms. Sequence starts with 6, 9, 2, 15, 14, 1, 3, 3, 9 which are f, i, b, o, n, a, c, c, i if you consider a=1, b=2, c=3, ..., z=26.

The sequence begins 6, 9, 2, 15, 14, 1, 3, 3, 9, 62, 118, 227, 452, 889, 1764, 3527, 7051, 14099, 28189, ...

I only chanced upon this sequence because 28189, my diurnal age today, is a member. I've written about the various connections between numbers and letters in a post titled Days of the Year and Gematria back in August of 2021. The idea behind this sequence reminds me of my own approach described in a blog post titled Consolidating Fibonacci-like Numbers where I considered numbers whose digits following a Fibonacci pattern e.g. 21347:$$21347 \text{ where }2 + 1 =3, 1+3=4,3+4=7$$However, getting back to approach followed in OEIS A129938, an interesting "spin-off" could be that previously unnamed tribonacci sequences could be given memorable names. For example, using Table 1 we could write:$$ \text{ cat } \rightarrow \text{ c, a, t } \rightarrow \text{ 3, 1, 20 }$$and so the "cat" sequence becomes:$$3, 1, 20, 24, 45, 79, \dots$$Similarly we have:$$ \text{ dog } \rightarrow \text{ d, o, g } \rightarrow \text{ 4, 15, 7 }$$ So the "dog" sequence becomes:$$4, 15, 7, 26, 48, 81, \dots$$Silly I know but it would make for an interesting puzzle in Puzzle of the DayThe sequence doesn't have to be tribonacci, it could simply be Fibonacci-like. For example, we could ask why is the sequence 13, 5, 18, 23, 41, 65, ... egocentric? The answer is that:$$13, 5 \rightarrow \text{ m, e } \rightarrow \text{ me }$$Similarly, the sequence could be made of four or more seeds and a puzzle created. For example, we could ask what does this sequence 13, 9, 12, 11, 45, 77, ... and the Milky Way have in common? The answer is that the first four members of the sequence are the seeds to generate the future members of the sequence and we have:$$ 13, 9, 12, 11 \rightarrow \text{ m, i, l, k } \rightarrow \text{ milk}$$That's enough nonsense for the moment but let's not forget that there has always been a long-standing connection between letters of certain alphabets (Hebrew, Ancient Greek and Arabic for example) and numbers. With the English language the connection has weakened but it's still there and not just in the way shown in Table 1. There are other ways to assign values to letters in the English alphabet. Table 2 shows an alternative way that is more in keeping with the ancient languages.


Table 2: source

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$

Wednesday, 14 February 2024

A Fibonacci Variant

I was happy to discover a variant of the famous Fibonacci sequence today when I began searching the OEIS for properties of the number associated with my diurnal age today: 27345. Let's look at OEIS  A321021:


 A321021

a(0)=0, a(1)=1; thereafter a(\(n\)) = a(\(n\)-2)+a(\(n\)-1), keeping just the digits that appear exactly once.



This is a Fibonacci-like sequence in that the next term is formed from the sum of the two previous terms but the fact that we keep only the digits that appear exactly once in this addend makes a huge difference. After 171 terms, the sequence enters a 100 term loop shown in blue below with 27345 marked in bold (permalink):

0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 0, 34, 34, 68, 102, 170, 7, 1, 8, 9, 17, 26, 43, 69, 2, 71, 73, 1, 74, 75, 149, 4, 153, 157, 310, 467, 0, 467, 467, 934, 40, 974, 4, 978, 982, 1960, 94, 2054, 2148, 40, 21, 61, 82, 143, 5, 148, 153, 301, 5, 306, 3, 309, 312, 621, 9, 630, 639, 1269, 1908, 31, 13, 0, 13, 13, 26, 39, 65, 104, 169, 273, 2, 275, 2, 2, 4, 6, 10, 16, 26, 42, 68, 0, 68, 68, 136, 204, 340, 5, 345, 350, 695, 1045, 1740, 2785, 42, 87, 129, 216, 345, 561, 906, 1467, 27, 19, 46, 65, 0, 65, 65, 130, 195, 325, 520, 845, 1365, 10, 1375, 1385, 2760, 15, 25, 40, 65, 105, 170, 275, 5, 280, 285, 6, 291, 297, 5, 302, 307, 609, 916, 12, 928, 940, 16, 956, 972, 1928, 29, 1957, 1986, 94, 28, 1, 29, 30, 59, 89, 148, 237, 385, 6, 391, 397, 7, 0, 7, 7, 14, 21, 35, 56, 91, 147, 238, 385, 623, 18, 641, 659, 13, 672, 685, 1357, 4, 36, 40, 76, 6, 82, 0, 82, 82, 164, 246, 410, 5, 415, 420, 835, 12, 847, 859, 1706, 26, 1732, 1758, 3490, 5248, 73, 5321, 5394, 75, 5469, 0, 5469, 5469, 10938, 16407, \( \textbf{27345} \), 43752, 109, 43861, 43970, 731, 701, 1432, 21, 1453, 17, 1470, 1487, 2957, 0, 2957, 2957, 5914, 71, 98, 169, 267, 436, 703, 39, 742, 781, 1523, 2304, 3827, 63, 3890, 95, 3985, 48, 40, 0, 40, 40, 80, 120, 2, 1, 3, 4, 7, 0, 7, 7, 14, 21, 35, ...

Thus 27345 is a term in this 100 term loop and this qualifies it for membership in OEIS  A321022:


 A321022

The 100 terms of the cycle that A321021 goes into.   
          


As with the Fibonacci sequence, this Fibonacci-like sequence need not begin with 0 and 1 but could be a Lucas-like sequence beginning with 2 and 1:

2, 1, 3, 4, 7, 0, 7, 7, 14, 21, 35, 56, 91, 147, 238, 385, 623, 18, 641, 659, 13, 672, 685, 1357, 4, 36, 40, 76, 6, 82, 0, 82, 82, 164, 246, 410, 5, 415, 420, 835, 12, 847, 859, 1706, 26, 1732, 1758, 3490, 5248, 73, 5321, 5394, 75, 5469, 0, 5469, 5469, 10938, 16407, 27345, 43752, 109, 43861, 43970, 731, 701, 1432, 21, 1453, 17, 1470, 1487, 2957, 0, 2957, 2957, 5914, 71, 98, 169, 267, 436, 703, 39, 742, 781, 1523, 2304, 3827, 63, 3890, 95, 3985, 48, 40, 0, 40, 40, 80, 120, 2, 1, 3, 4, 7, 0, 7, 7, 14, 21, 35, 56, ...

Again we end up with the same cycle of 100 terms, it just starts a little earlier. One can also try a tribonacci approach with starting points of 0, 1 and 2. This gives a loop of almost 1000 terms (permalink) with a maximum value reached of 120487 (shown in bold red):

0, 1, 2, 3, 6, 0, 9, 15, 24, 48, 87, 159, 294, 540, 3, 837, 1380, 0, 17, 1397, 0, 0, 1397, 1397, 2794, 0, 49, 2843, 89, 2981, 5913, 93, 97, 6103, 6293, 12493, 249, 19035, 31, 935, 21, 987, 1943, 2951, 51, 95, 3097, 24, 3216, 67, 7, 3290, 64, 61, 3415, 3540, 7016, 397, 10953, 183, 5, 4, 192, 201, 397, 790, 13, 12, 815, 840, 17, 1672, 59, 1748, 3479, 5286, 53, 1, 5340, 5394, 10735, 21469, 37598, 69802, 1269, 1089, 72160, 74518, 146, 1682, 734, 56, 47, 837, 940, 1824, 3601, 35, 5460, 6, 1, 5467, 57, 2, 26, 85, 3, 4, 92, 0, 96, 1, 97, 194, 9, 3, 206, 218, 427, 851, 1496, 24, 2371, 3891, 28, 6290, 129, 67, 48, 2, 7, 57, 0, 64, 2, 0, 0, 2, 2, 4, 8, 14, 26, 48, 0, 74, 1, 75, 150, 6, 231, 387, 624, 14, 1025, 13, 1052, 29, 1094, 2175, 3298, 57, 30, 85, 172, 287, 5, 6, 298, 309, 613, 10, 932, 1, 943, 1876, 80, 28, 1984, 9, 1, 14, 24, 39, 0, 63, 102, 165, 0, 267, 432, 6, 705, 43, 754, 1502, 0, 56, 18, 74, 148, 240, 462, 850, 12, 1324, 2186, 35, 34, 0, 69, 103, 172, 3, 278, 453, 734, 1465, 65, 64, 1594, 1723, 81, 98, 1902, 2081, 4081, 8064, 146, 9, 8219, 8374, 102, 195, 8671, 96, 8962, 129, 9187, 127, 93, 9407, 9627, 927, 6, 156, 1089, 25, 1270, 2384, 3679, 7, 67, 75, 149, 291, 1, 1, 293, 295, 589, 0, 4, 593, 597, 94, 1284, 1975, 5, 3264, 52, 21, 7, 80, 108, 195, 8, 3, 206, 217, 426, 849, 1492, 26, 2367, 35, 48, 2450, 25, 53, 58, 136, 247, 1, 384, 632, 7, 1023, 12, 1042, 20, 1074, 2136, 20, 20, 2176, 16, 1, 2193, 10, 4, 7, 21, 32, 60, 3, 95, 158, 256, 509, 923, 16, 18, 957, 1, 976, 1934, 29, 23, 1986, 2038, 7, 4031, 7, 5, 3, 15, 23, 41, 79, 143, 263, 485, 891, 1639, 3015, 4, 4658, 6, 48, 4712, 47, 4807, 95, 0, 4902, 47, 0, 0, 47, 47, 94, 1, 142, 237, 380, 759, 1376, 21, 2156, 0, 21, 21, 42, 84, 147, 273, 504, 924, 70, 1498, 49, 67, 64, 180, 3, 247, 430, 680, 1357, 2467, 50, 3874, 6391, 35, 13, 6439, 6487, 123, 13049, 165, 17, 2, 184, 203, 389, 6, 598, 3, 607, 1208, 0, 85, 1293, 1378, 2756, 5427, 9561, 1, 148, 9710, 85, 43, 93, 1, 137, 231, 369, 3, 603, 975, 58, 13, 1046, 7, 10, 1063, 18, 9, 19, 46, 74, 139, 259, 472, 870, 60, 1402, 0, 1462, 2864, 4326, 8652, 15842, 0, 29, 587, 1, 617, 1205, 1823, 3645, 73, 41, 3759, 87, 37, 0, 124, 6, 130, 260, 396, 786, 12, 94, 892, 8, 4, 904, 916, 1824, 36, 26, 16, 78, 120, 214, 412, 746, 1372, 2530, 68, 3970, 58, 4096, 8124, 178, 12398, 27, 12603, 508, 8, 39, 0, 47, 86, 1, 134, 1, 136, 271, 408, 815, 19, 14, 4, 37, 0, 41, 78, 9, 128, 215, 352, 695, 16, 1063, 14, 1093, 2170, 32, 3295, 5497, 24, 16, 37, 0, 53, 90, 143, 286, 519, 948, 1753, 30, 2731, 51, 81, 2863, 25, 26, 2914, 2965, 90, 56, 3, 149, 208, 360, 1, 569, 930, 15, 54, 0, 69, 123, 192, 384, 6, 582, 972, 1560, 34, 25, 69, 128, 0, 197, 325, 5, 527, 857, 1389, 23, 69, 48, 140, 257, 5, 402, 4, 4, 410, 418, 832, 10, 1260, 10, 1280, 20, 30, 10, 60, 1, 71, 132, 204, 407, 743, 1354, 2504, 4601, 8459, 164, 134, 85, 8, 7, 1, 16, 24, 41, 81, 146, 268, 495, 0, 763, 1258, 1, 0, 1259, 1260, 2519, 5038, 17, 54, 5109, 5180, 104, 109, 59, 7, 175, 241, 423, 839, 1503, 2765, 5107, 9375, 124, 140, 63, 327, 530, 920, 1, 45, 9, 0, 54, 63, 7, 124, 194, 325, 643, 62, 13, 718, 793, 1524, 5, 3, 1532, 1540, 3075, 6147, 10762, 184, 17093, 28039, 45316, 908, 74263, 120487, 1968, 9678, 2, 648, 10328, 10978, 21954, 43260, 76192, 6, 9458, 8, 9472, 193, 9673, 198, 164, 135, 497, 796, 1428, 71, 95, 1594, 1760, 39, 9, 10, 58, 0, 68, 126, 194, 3, 2, 1, 6, 9, 16, 31, 56, 103, 190, 349, 642, 8, 0, 650, 658, 1308, 21, 1987, 16, 4, 27, 47, 78, 152, 2, 3, 157, 162, 3, 3, 168, 174, 345, 687, 1206, 38, 93, 17, 148, 258, 423, 829, 50, 1302, 28, 1380, 2710, 48, 4138, 89, 4275, 8502, 128, 12905, 213, 13246, 234, 169, 13649, 14052, 280, 27981, 421, 6, 240, 7, 253, 5, 265, 523, 793, 58, 1374, 5, 1437, 2816, 4258, 85, 7159, 502, 46, 0, 548, 594, 42, 84, 720, 846, 1650, 3216, 5712, 10578, 19506, 35796, 650, 92, 658, 14, 764, 1436, 14, 14, 16, 0, 30, 46, 76, 152, 274, 502, 928, 1704, 14, 24, 1742, 1780, 3546, 7068, 12394, 238, 197, 189, 624, 0, 813, 1437, 50, 23, 50, 123, 196, 369, 6, 571, 946, 1523, 34, 2503, 46, 2583, 5132, 61, 6, 51, 8, 65, 124, 197, 386, 0, 583, 6, 589, 78, 673, 1340, 2091, 10, 31, 13, 54, 98, 165, 317, 580, 1062, 15, 1657, 2734, 6, 4397, 13, 16, 26, 0, 42, 68, 0, 0, 68, 68, 136, 7, 2, 145, 154, 301, 6, 461, 768, 1235, 26, 9, 1270, 1305, 2584, 19, 3908, 65, 32, 45, 142, 219, 406, 6, 631, 1043, 1680, 54, 2, 1736, 1792, 50, 3578, 5420, 9048, 18046, 32514, 59608, 68, 210, 596, 874, 1680, 3150, 5704, 10534, 193, 643, 370, 1206, 19, 19, 12, 50, 81, 143, 274, 498, 915, 1687, 31, 26, 17, 74, 7, 98, 179, 284, 561, 1024, 1869, 35, 98, 0, 1, 0, 1, 2, 3, ...

Sunday, 18 July 2021

Free Fibonacci Sequences

On turning 26404 days, I couldn't help but notice the 404, a number made famous by the experience of everyone who has searched the Internet and failed to find what was being sought.

Apart from containing 404 as a subset of its digits, 26404 has some other interesting properties. Foremost amongst these is the fact that it is a member of OEIS A008892.


 A008892

Aliquot sequence starting at 276.                         

I wrote about aliquot sequences in an eponymous post of December 20th 2017 and again, only recently, in Aliquot Sequences Revisited on June 21st 2021. 276 is the first of a sequence of numbers that are not known to be finite or periodic when the aliquot algorithm is applied. This algorithm takes as its input any integer \(n\) and returns the sum of the number's aliquot parts or proper divisors, \( \sigma(n)-n\). This output serves as the new input and the process is repeated until, most commonly, a prime number \(p\) is reached. Since \( \sigma(p)-p=1\), this means the process terminates because \( \sigma(1)=0\).

For some numbers, as far as can be determined, the process never terminates. These numbers include:

276, 306, 396, 552, 564, 660, 696, 780, 828, 888, 966, 996, 1074, 1086, 1098, 1104, 1134, 1218, 1302, 1314, 1320, 1338, 1350, 1356, 1392, 1398, 1410, 1464, 1476, 1488, ... and forming OEIS A131884 

In the case of 276, the sequence of numbers up to and including 26404 is:

276, 396, 696, 1104, 1872, 3770, 3790, 3050, 2716, 2772, 5964, 10164, 19628, 19684, 22876, 26404

However, this post is mainly about another interesting property of 26404 and that is its membership of OEIS A232666:


 A232666

6-free Fibonacci numbers.                                         


The OEIS comment is that:
The sequences of \(n\)-free Fibonacci numbers were suggested by John H. Conway. \(a(n)\) is the sum of the two previous terms divided by the largest possible power of 6. The sequence coincides with the Fibonacci sequence until the first multiple of 6 in the Fibonacci sequence: 144, which in this sequence is divided by 36 to produce 4.

The sequence of numbers leading to 26404 in OEIS A232666 is:

0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 4, 93, 97, 190, 287, 477, 764, 1241, 2005, 541, 2546, 3087, 5633, 8720, 14353, 23073, 37426, 60499, 97925, 26404
Here is the permalink to the generation of this sequence. There is a paper titled Free Fibonacci Sequences by Brandon Avila and Tanya Khovanova that appears in the Journal of Integer Sequences (Vol. 17 (2014), Article 14.8.5) that analyses these sequences in some detail. The authors of the paper write:
Let us denote Fibonacci numbers by \(F_k\). We define our indices such that \(F_0 = 0\) and \(F_1 = 1\). The sequence is defined by the Fibonacci recurrence: \(F_{n+1} = F_n + F_{n−1} \) (see OEIS A000045). We call an integer sequence \(a_n\) Fibonacci-like if it satisfies the Fibonacci recurrence: \(a_k = a_{k−1} + a_{k−2}\). A Fibonacci-like sequence is similar to the Fibonacci sequence, except that it starts with any two integers. The second most famous Fibonacci-like sequence is the sequence of Lucas numbers \(L_i\) that starts with \(L_0 = 2\) and \(L_1 = 1\): \(2, 1, 3, 4, 7, 11, \dots \) (see OEIS A000032). 
An \(n\)-free Fibonacci sequence starts with any two integers, \(a_1\) and \(a_2\), and is defined by the recurrence:$$a_k = \frac{a_{k−1} + a_{k−2}}{n^{ν_n(a_{k−1}+a_{k−2})}}$$where \(ν_n(x)\) is the exponent of the largest power of \(n\) that is a divisor of \(x\). To continue the tradition, we call numbers in the \(n\)-free Fibonacci sequence that starts with \(a_0 = 0\) and \(a_1 = 1\) \(n\)-free Fibonacci numbers.

The authors then go on to look at a variety of \(n\)-free Fibonacci sequences. They start with 2-free Fibonacci sequences and find that they all end in a cycle of length 1. For example, starting with \(a_0=5\) and \(a_1=10\) gives:$$5, 10, 15, 25, 5, 15, \overbrace{5}, \dots$$For 3-free Fibonacci sequences, it is suspected that all end in a cycle of \(k, k, 2k\) but it has not been proven. For example, starting with \(a_0=3\) and \(a_1=7\) gives:$$3, 7, 10, 17, 1, 2, \overbrace{1, 1, 2}, \dots$$with 1, 1, 2 repeating. Similarly, taking \(a_0=13\) and \(a_1=7\), the sequence generated is$$13, 7, 20, 1, 7, 8, 5, 13, 2, 5, 7, 4, 11, 5, 16, 7, 23, 10, 11, 7, 2, \overbrace{1, 1, 2} \dots$$ with 1, 1, 2 again repeating. The authors then go on to say that:

Consider the 4-free Fibonacci sequence starting with 0, 1. This sequence is OEIS A224382: 0, 1, 1, 2, 3, 5, 2, 7, 9, 1, 10, 11, 21, 2, 23, 25, .... It seems that this sequence grows and does not cycle. In checking many other 4-free Fibonacci sequences, we still did not find any cycles. The behaviour of 4-free sequences is completely different from the behaviour of 3-free sequences. For 3-free sequences, we expected that all of them cycle. Here, it might be possible that none of them cycles.

Let us look at the Lucas sequence mod 5: 2, 1, 3, 4, 2, 1, ... and see that no term is divisible by 5. Clearly, no term in the Lucas sequence will require that we factor out a power of 5, and the terms will grow indefinitely. Thus, the Lucas sequence is itself a 5-free Fibonacci sequence. On the other hand, it becomes quickly evident that the sequence of 5-free Fibonacci numbers: 0, 1, 1, 2, 3, 1, 4, 1, 1, 2, ... (see OEIS A214684) cycles. Some sequences cycle, and some clearly do not!


John Conway: 1937 - 2020

At the beginning of the paper, it's said that "John Horton Conway likes playing with the Fibonacci sequence. Instead of summing the two previous terms, he sums them up and then adds a twist: some additional operation." Of course, at that time, John Conway was still alive. He only died on April 11th 2020. That's a good way of thinking about the free Fibonacci sequences: Fibonacci with a twist!

I've posted frequently about Fibonacci sequences:

The paper contains more detailed information but the takeaway is that there is plenty of scope for further investigation of Fibonacci-like sequences with a twist. Consider this "twist" on the tribonacci sequence with initial terms of 0, 1 and 2. Each successive term is the sum of the previous three terms but (and here's the twist), if the result is a composite number, replace the term with the composite number's highest prime factor. The first terms are:

0, 1, 2, 3, 3, 2, 2, 7, 11, 5, 23, 13, 41, 11, 13, 13, 37, 7, 19, 7, 11, 37, 11, 59, 107, 59, 5, 19, 83, 107, 19, 19, 29, 67, 23, 17, 107, 7, ...

So what's going on. Well, a plot of the first 400 terms reveals the story. See Figure 1.


Figure 1: permalink

This composite number to highest prime factor "twist" is just something that popped into my head and it instantly yielded a most interesting result: a quick spike and then settling into a cycle after 255 terms. Figure 2 shows the first 1000 terms and the cycles are evident.


Figure 2: permalink

The dramatic rise and fall of the terms and their settling into an endless loop, with its own dramatic peak, are unexpected but that is what happens.

Saturday, 13 July 2019

The Connectivity of Numbers

Figure 1
I thought it time to summarise what I've learned thus far about the number properties that I'll term intrinsic. By this term, I mean number properties that are not dependent on the number base used to represent the number. For example, 25652 is a palindromic number in base 10 but Figure 1 shows that this is not the case for the other bases from 2 to 16. Examples of intrinsic number properties would be the number of prime factors and the number of divisors. For example, 25652 factors to \(2^2 ⋅ 11^2 ⋅ 53\) and it has 18 divisors (1, 2, 4, 11, 22, 44, 53, 106, 121, 212, 242, 484, 583, 1166, 2332, 6413, 12826 and 25652). These factors and divisors are the same numbers in any number base.

The sum of the digits of a number is another example of a number property that is not intrinsic. In the case of 25652, the digit sum is 20. However, in base 8 the number is 62064 and the digit sum is \(22_8\), which is 18 in base 10. Contrast this with the sum of the prime factors of 25652 in bases 10 and 8 (ignoring multiplicity). In base 10, the sum is 66. In base 8, the factors are \(2_8\), \(13_8\) and \(65_8\) and so the sum is \(102_8\) or 66 in base 10. So having clarified the difference between intrinsic and base-dependent number properties, what are some of the most important properties of the former type of numbers?

I'll continue using 25652 as an example. To begin the divisors, and particularly the prime divisors, are all important. For 25652, as already noted, the divisors are:$$1, 2, 4, 11, 22, 44, 53, 106, 121, 212, 242, 484, 583, 1166, 2332, 6413, 12826, 25652$$The prime divisors are \( 2, 2, 11, 11, 53 \) and these uniquely define the number. 25652 has an interesting property that does not relate to its own divisors but instead relates to the proper divisors of other numbers. 25652 is an untouchable number, because it is not equal to the sum of proper divisors of any number. The proper divisors of 25652 are 1, 2, 4, 11, 22, 44, 53, 106, 121, 212, 242, 484, 583, 1166, 2332, 6413, 12826 and these add to 25137. This means that 25137 is not an untouchable number because it can be formed from the addition of the proper divisors of 25652. This talk of adding up divisors leads us on to the sigma function.

The sigma function can be used to find the number of divisors, the sum of these divisors, the sum of the squares of these divisors, the sum of the cubes of these divisors and so on. So-called sigma zero, written as \( \sigma_0\), returns the number of divisors or the sum of the divisors raised to the zero power. \( \sigma_1\) returns the sum of the divisors raised to the first power and so on. This is the result:

\( \sigma_0(25652)=18\)
\( \sigma_1(25652)=50274\)
\( \sigma_2(25652)=871164630\)
\( \sigma_3(25652)=19267967775942\)
Also of interest is the count of numbers that are relatively prime to 25652 where 1 is regarded as being relatively prime to all numbers. This is known as the totient of the number and can be written as \( \phi=11440 \). All multiples of 2, 11 and 53 (and 25652 itself) will be excluded from this count. For prime numbers, the totient will always be one less than the number itself. For example, 25667 is prime and its totient is 25666.

Moving along, we note that some numbers are so-called square numbers. An example of such a number is 25600 which is equal to the square of 160. Visually, this number could be represented as shown in Figure 2.

Figure 2

In the case of 25652, it is not a square number but it can be represented a sum of two squares, since$$25652=23716 + 1936 = 154^2 + 44^2 $$So, visually, the number could be represented as shown in Figure 3:

Figure 3

Only certain numbers can be represented as a sum of two squares. If a number has a 4k+3 prime factor that is raised to an odd number (1, 3, 5, .. ), then it cannot be represented as a sum of two squares. Most numbers can be represented as sum of three squares, provided that there is not a remainder of 7 when the number is divided by 8. 25652 gives a remainder of 4 when divided by 8 and it can be represented as a sum of three squares in 20 different ways as shown in Figure 4:

Figure 4
Figure 5

Visually, the nineteen triplets in Figure 4 that contain no zeroes, could be used as the sides of three squares, to represent 25652. The same approach can be used for cubes. For example:$$25665=11^3+23^3+23^3$$Rather less frequently, a number can be represented as a sum of two cubes. For example:$$25720 = 11^3 + 29^3 $$Such numbers can be envisaged as comprising three cubes (in the case of 25665) or two cubes (in the case of 25720). See Figure 5 for a not-to-scale representation of 25720.

In my previous post, I considered the seed numbers that would be needed to make a number a part of a Fibonacci sequence. In the case of 25652, these numbers would be 52 and 146, producing the sequence:$$25652,15854,9798,6056,3742,2314,1428,886,542,344,198,146,52$$Similarly, the three seed numbers for 25652 to be part of a tribonacci sequence are 10, 30 and 63, producing the sequence:$$25652,13947,7583,4122,2242,1219,661,362,196,103,63,30,10$$So I could go on but I'll leave off there and try to summarise things via Figure 6.

Figure 6

Friday, 12 July 2019

Finding Fibonacci and Tribonacci Seed Numbers

Today I turned 25667 days old. This number is prime but there is little of interest to be found concerning its properties in either the OEIS or NumbersAplenty, my usual resources. For a while now, the idea that every number could be considered as being part of a Fibonacci sequence has been knocking around in my head.

Today the idea came into focus when I started to look at 25667 in this light. I knew that the ratio of consecutive terms in a Fibonacci sequence approached closer and closer to the Golden Ratio as the terms got larger. I figured I'd use this property to find the previous term.$$ \frac{25667}{\frac{1+ \sqrt {5}}{2}} \approx 15863.0783892436$$Rounding to the nearest whole number gives 15863 and from there it is easy to reverse engineer the remaining terms until a point is reached where the previous term is larger than the subsequent term. This is the point at which the algorithm I developed will stop.

Here is the SageMathCell permalink to the algorithm and Figure 1 shows a screenshot of the SageMath code.

Figure 1

The sequence of Fibonacci terms is:

25667 15863 9804 6059 3745 2314 1431 883 548 335 213 122 91 31

The two seed numbers are 31 and 91. Different numbers produce different sequences, even when only differing by 1. Consider the sequences for the two previous numbers: 25666 and 25665.

25666 15862 9804 6058 3746 2312 1434 878 556 322 234 88

25665 15862 9803 6059 3744 2315 1429 886 543 343 200 143 57

Of course, changing the manner in which the immediate predecessor of the starting number is calculated can affect the sequence. Suppose instead of rounding the decimal number, we simply truncated it, discarding the decimal part and leaving only the whole number. In the examples cited, the sequence remains the same for 25667 and 25666 but there is a difference in the case of 25655.

25665 15861 9804 6057 3747 2310 1437 873 564 309 255 54

The reason is that the decimal number is 15861.8423212660, so that rounding produces 15862 whereas truncating produces 15861. I think rounding is the better way to calculate the immediate predecessor of the starting number because this gives a result that is closest to the Golden Ration when the two numbers are compared. This benefit is clearly seen when a number from the classic Fibonacci sequence is entered e.g. 6765.

6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 
(using rounding)

6765 4180 2585 1595 990 605 385 220 165 55 
(using truncation)

Now every number can be associated with two seed numbers so that the three of them form part of a Fibonacci sequence.



Of course, the idea can be extended to tribonacci numbers with a slight modification of the code. Information about the tribonacci constant can be found here. Here is a permalink to the SageMathCell code and Figure 2 shows a screenshot of the SageMath code:

Figure 2

The sequence of tribonacci terms is:

25667 13955 7587 4125 2243 1219 663 361 195 107 59 29 19 11

So every number can be associated with three tribonacci seed numbers.


Sunday, 10 March 2019

Beyond Fibonacci

The Fibonacci sequence is the most famous example of a generalised sequence that begins with two seed numbers \( a \) and \( b \) and then proceeds as follows:$$ G_n=\begin{cases}a&\mbox{if }n=0;\\b&\mbox{if }n=1;\\G_{n-1}+G_{n-2}&\mbox{otherwise.}\end{cases} $$So \(G_3=b+a \), \(G_4=a+2b \) etc. It can be shown that the \(n\)-th term in the Fibonacci sequence is given by \( [ \phi ]^n/ \sqrt 5 \) (where the square brackets denote rounding to the nearest whole number) and so the question could be asked is there a general formula for calculating the \(n\)-th term of the generalised sequence \(a, b, a+b, a+2b, ... \)? Well, after watching this Numberphile video, it turns out that there is:


The formula is:$$G_n=\bigg [ \phi ^n \times \frac{(3 \sqrt 5 - 5) \, a + (5 - \sqrt 5) \, b}{10} \bigg ] $$When \(a=1\) and \(b=1\), we get \( [ \phi ]^n/ \sqrt 5 \) so all is well. When \(a=1 \) and \(b=3 \), we get simply \( [ \phi ]^n  \) and this generates the Lucas numbers: 1, 3, 4, 7, 11, ...

The Numberphile video makes the point that it is the number \( \sqrt 5 \) that is at the heart of this formula and thus underlies all these Fibonacci-like sequences that are generated from two seed numbers.

We can also consider not two but three seed numbers and this leads to what is called the Tribonacci sequence defined by:$$
T_n=\begin{cases}0&\mbox{if }n=0\\1&\mbox{if }n=1\\1&\mbox{if }n=2\\T_{n-1}+T_{n-2}+T_{n-3}&\mbox{if }n \geq 3\end{cases}

$$This leads to 0, 1, 1, 2, 4, 7, 13, 24, 44, 81, 149, 274, 504, 927, ... and, just as the closed-form formula for the Fibonacci sequence involved the roots of the polynomial \(x^2-x-1\), it is reasonable to expect that the analogous formula for the tribonacci sequence involves the polynomial \(x^3-x^2-x-1\) and this is indeed the case. This polynomial has one real root:$$ \frac{1}{3} \bigg ( 1+ \sqrt[3] {19+ 3 \, \sqrt {33}} + \sqrt[3] {19 -\sqrt {33}} \bigg ) \approx 1.83929 $$ called the tribonacci constant and this is the ratio of successive pairs of terms. In other words:$$

\lim_{n \to \infty} \frac {T_{n+1}}{T_n}=\frac{1}{3} \bigg ( 1+ \sqrt[3] {19+ 3 \, \sqrt {33}} + \sqrt[3] {19 -\sqrt {33}} \bigg ) \approx 1.83929

$$The other two roots are complex conjugates (source). The generating function for the tribonacci numbers is quite similar to the generating function for the Fibonacci numbers:$$ \sum_0 ^ \infty \! T_n \, x^n = \frac {x}{1-x-x^2-x^3} $$