Showing posts with label Fibonacci. Show all posts
Showing posts with label Fibonacci. Show all posts

Thursday, 25 June 2026

Reverse Engineering Part 3

In my previous post, Reverse Engineering Part 2, I ended up being quite satisfied with the reverse engineering that created as output an homogenous linear recurrence relation of order 3 after input of any positive integer greater than 9. I used 28206 and 28207 as examples to illustrate the process.

This got me thinking about creating as output an homogenous linear recurrence relation of order 2 after input of any positive integer greater than 9. I explained in my post Reverse Engineering Part 1 that Gemini's algorithm had failed when attempting this. I was trying to get Gemini to create the following:$$ \begin{align} &\text{a}(n)=p \times \text{a}(n-1)+q \times \text{a}(n-2) \\ &\text{where} -9 \leq p,q \leq 9 \text{ with } p \neq 0 \text{ and } q \neq 0 \\ &\text{ and } 0 \leq \text{a}(n-1), \text{a}(n-2) \leq 9 \end{align}$$So I asked Gemini to relax the conditions by specifying that \( |p + q|\) should be as small as possible. When applied to 28207 this produced values \(p=39\) and \(q=-38\). Not quite what I wanted. So in the end I specified that \(|p^2+q^2+a(0)^2+a(1)^2|\) should be as small as possible. Applied to 28206, this was the result (permalink):

Target Number: 28206
--------------------------------------------------
Constants found: p = 13, q = 1
Constraint check: Minimum p^2 + q^2 + a(0)^2 + a(1)^2 = 395
Seed numbers:    a(0) = 9, a(1) = 12
--------------------------------------------------
Sequence progression:
  a(0) = 9
  a(1) = 12
  a(2) = 165
  a(3) = 2157
  a(4) = 28206
--------------------------------------------------
Comma-separated sequence:
9, 12, 165, 2157, 28206

Applied to 28207, this was the result (permalink):

 Target Number: 28207

--------------------------------------------------
Constants found: p = 6, q = 5
Constraint check: Minimum p^2 + q^2 + a(0)^2 + a(1)^2 = 231
Seed numbers:    a(0) = 11, a(1) = 7
--------------------------------------------------
Sequence progression:
  a(0) = 11
  a(1) = 7
  a(2) = 97
  a(3) = 617
  a(4) = 4187
  a(5) = 28207
--------------------------------------------------
Comma-separated sequence:
11, 7, 97, 617, 4187, 28207

Overall I'm quite happy with these sequences. All terms are positive, the coefficients and seed values are not large and the terms increase steadily toward their targets, avoiding any wild gyrations. I have incorporated this program 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

Saturday, 9 May 2026

Horadam Sequences

A Horadam sequence is a generalization of the Fibonacci numbers defined by the four constants (\(p,q,r,s\)) and the definitions \(H_0=p\) and \(H_1=q\) together with the linear recurrence equation for \(n>1\):$$H_n=sH_{n-1}+rH_{n-2}$$Specific values of \(r\) and \(s\) lead to well known sequences:

  • Fibonacci Numbers: \(F_n=F_{n-1}+F_{n-2}\\ \text{ where }n \geq 2, F_0=0, F_1=1\)
     
  • Lucus Number: \(L_n=L_{n-1}+L_{n-2} \\ \text{ where } n \geq 2, L_0=2, L_1=1\)

  • Pell Numbers: \(P_n=2P_{n-1}+P_{n-2} \\ \text{ where } n \geq 2, P_0=0, P_1=1\)

  • Pell-Lucus Numbers: \(Q_n=2Q_{n-1}+Q_{n-2} \\ \text{ where } n \geq 2, Q_0=Q_1=1\)

  • Jacobsthal Numbers: \(J_n=J_{n-1}+2J_{n-2} \\ \text{ where } n \geq 2, J_0=0, J_1=1 \)

  • Jacobsthal-Lucas Numbers: \( j_n=j_{n-1}+2j_{n-2} \\ \text{ where } n \geq 2, j_0=j_1=2\)

Today I turned 28160 days old and this number is a member of OEIS A085449:


 A085449: Horadam sequence (0,1,4,2)

The numbers indicate that the sequence is generated as follows for \(n>1\):$$H_n=2H_{n-1}+4H_{n-2}$$with \(H_0=0\), \(H_1=1\), \(r=4\) and \(s=2\)

The sequence begins: 0, 1, 2, 8, 24, 80, 256, 832, 2688, 8704, 28160

The generating function is:$$ \frac{x}{1-2x-4x^2}$$The progressive ratios between successive terms approach the following number:$$ \frac{H_n}{H_{n-1}} \rightarrow 2\phi = \sqrt{5}+ 1 \text{ as }n \text{ gets larger}$$In the general case we have:$$ \frac{H_n}{H_{n-1}} \rightarrow \frac{r}{s} \phi = \frac{r}{s} (\sqrt{5}+ 1) \text{ as }n \text{ gets larger}$$Oddly, the name Horadam does not appear in the MacTutor biographies of mathematicians but Gemini provided the following summary of his life and work:

Alwyn Francis ("Horrie") Horadam (1923–2016)

Alwyn Francis ("Horrie") Horadam was a prominent Australian mathematician best known for his extensive work in number theory and for generalizing second-order linear recurrences.

Here is a comprehensive overview of his life, career, and the mathematical sequences that bear his name.


Early Life and Education

Horadam was born on March 22, 1923, to a family of dairy farmers in the rural settlement of Scotts Flat in the Hunter Valley of New South Wales, Australia. His dedication to education was evident early on; during the Great Depression, he traveled 110 kilometers round-trip by train every day just to attend high school in Maitland, all while managing farm duties before and after his commute.

He went on to graduate with First Class Honours in Mathematics from the University of Sydney in 1944. He later earned a BEd from the University of Melbourne and a PhD from the University of Sydney, focusing his early doctoral research on Clifford geometry in complex projective spaces.

Academic Career at UNE

Horadam spent nearly his entire 40-year academic career at the University of New England (UNE) in Armidale, New South Wales. Starting as a lecturer in 1947, he eventually progressed to Professor of Mathematics and served as the Dean of the Faculty of Science.

Beyond his research, he was widely regarded as a deeply committed and generous educator. He served on the New South Wales Junior School Mathematics Committee for 25 continuous years, co-authored several high school mathematics textbooks, and maintained an open-door policy for his university students throughout his tenure.

The Horadam Sequence

While Horadam's early interests included geometry and algebra, his most lasting mathematical legacy lies in number theory—specifically, his generalization of integer sequences. Introduced in a series of papers in the 1960s, the Horadam sequence, commonly denoted as Wn(a, b; p, q), provides a unified framework for second-order linear recurrences.

The sequence is defined by two initial conditions:

W0 = a
W1 = b

And the recurrence relation for n ≥ 2:

Wn = pWn-1 - qWn-2

(Note: Depending on the specific convention used in various literature, the recurrence is sometimes written as Wn = pWn-1 + qWn-2.)

By altering the four parameters (a, b, p, q), the Horadam sequence acts as a parent to many famous recursive sequences:

  • Fibonacci Numbers: Generated by setting a=0, b=1, p=1, and q=-1.
  • Lucas Numbers: Generated by setting a=2, b=1, p=1, and q=-1.
  • Pell Numbers: Generated by setting a=0, b=1, p=2, and q=-1.

This generalization allowed mathematicians to prove broad identities and Binet-style formulas that apply universally to all these sequences at once, rather than analyzing them in isolation.

Legacy in Sequence Analysis

Horadam's generalizations paved the way for modern, systematic analysis of recurrence relations. He was a foundation and sustaining member of the Fibonacci Association and served extensively on the editorial board of the Fibonacci Quarterly. Over his lifetime, he published widely on combinatorial structures, generating functions, and sequence periodicities.

He continued his research well into his retirement, publishing his final papers in 2006. Horadam passed away in Armidale in 2016 at the age of 93, leaving behind a profound legacy in both Australian mathematical education and global number theory.

Interestingly his wife was a fellow mathematician and clearly an impressive woman:

Eleanor Mollie Horadam (née Spedding) (1921–2002)

Eleanor Mollie Horadam was a highly accomplished mathematician in her own right, with a fascinating career and a lasting legacy in Australian academia. She was the wife of Alwyn Francis Horadam.


Early Life and World War II

Born on June 29, 1921, in Yorkshire, England, to a suffragette mother and a pharmacist father, Mollie demonstrated early academic brilliance. She studied the Mathematical Tripos at Girton College, Cambridge, earning her BA in 1942. However, because Cambridge did not allow women to receive degrees at public graduation ceremonies at the time, she was not publicly conferred her degree until she returned on a sabbatical in 1956.

During World War II, she worked in the Stress Group at Rolls-Royce, performing stress-strain analyses on jet engines. While working by day, she took night classes in engineering at the University of London, ultimately earning a First Class Honours degree. During this time, she even outpaced early computing; when told it would take weeks to run a stress problem on the newly constructed Mark 1 computer in Manchester, she manually proved the exact mathematical solution much faster.

Move to Australia and Academic Career

Dissatisfied with post-war England's lack of opportunities and preference for promoting less-qualified men, Mollie emigrated alone to Australia in 1949 to take up a lectureship in mathematics and physics at the New England University College (which later became the University of New England, or UNE). It was here that she met fellow mathematics lecturer Alwyn Horadam, whom she married in 1950.

Mollie became a trailblazer for women in Australian academia. She successfully lobbied UNE to update its maternity policies, which allowed her to retain her lecturing position while raising their three daughters—a highly unusual achievement for the era. One of their daughters, Kathy Horadam, also went on to become a prominent Australian mathematician and Emeritus Professor at RMIT.

Mathematical Contributions

Inspired by lectures from J.E. Littlewood during her 1956 sabbatical at Cambridge, Mollie shifted her focus to number theory at the age of 35. Over the next decade, she published more than 30 research papers, primarily focusing on the number theory of generalised integers and generalised prime numbers. This extensive body of research earned her a PhD by Prior Publication from UNE in 1965, leading to her promotion to Senior Lecturer. She also authored the textbook Principles of Mathematics for Economists.

In 1970, she broke another barrier by becoming the first female Sub-Dean of a faculty (Science) at UNE. Following her academic retirement in 1982, she established a successful commercial business dealing in antique silver. She was admitted as a Fellow of the University of New England in 1995. Mollie passed away in Armidale in 2002 at the age of 80, remembered as a pioneering intellect, a community leader, and a resilient force in a predominantly male profession.

Their eldest daughter followed in her parents' footsteps:

Alwyn and Mollie Horadam had three daughters: Kathryn (Kathy), Kerry, and Alanna. They also had a total of five granddaughters and one grandson.

The most publicly known of their children is their daughter Kathryn Jennifer Horadam (born in 1951 in Armidale), who followed in her parents' footsteps to become a highly accomplished and internationally recognized mathematician.


Kathryn Horadam's Career and Contributions

  • Education: She studied mathematics at the Australian National University, earning her bachelor's degree in 1972 and completing her PhD in 1977 with a dissertation titled The Homology of Groupnets.
  • Academic Career: She built a long and distinguished career at the Royal Melbourne Institute of Technology (RMIT), where she worked for over 30 years. She became a full professor of mathematics there in 1995 and currently holds the title of Emeritus Professor.
  • Research Focus: She is best known for her specialized research on Hadamard matrices and their applications in information security (keeping digital data safe). Outside of academia, she applied this expertise by working for three years with Australia's Defence Science and Technology Group.
  • Publications: She authored the comprehensive text Hadamard Matrices and Their Applications, published by Princeton University Press in 2007.
  • Recognition: Her impact on mathematics has been widely celebrated. She became a fellow of the Institute of Combinatorics and its Applications in 1991 and a fellow of the Australian Mathematical Society in 2001. In 2011, RMIT hosted a special international workshop on Hadamard matrices specifically in honor of her 60th birthday, with the resulting papers published in a special 2013 issue of the Australasian Journal of Combinatorics.

While Kathy pursued a high-profile academic career in mathematics like her parents, public details regarding the specific careers and lives of Kerry and Alanna are not prominently featured in public or academic records.

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\).

Sunday, 15 March 2026

There Can Be Only One 1

I've written about \(n\)-free Fibonacci sequences in a post titled Free Fibonacci Sequences, one example of which is the 6-free Fibonacci sequence described as follows:

The sequences of \(n\)-free Fibonacci numbers were suggested by John H. Conway. The 6-free Fibonacci sequence is created by 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 resulting numbers form 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

The sequence is base-independent but the "twist" I'm giving to the traditional Fibonacci sequence in this post is base-dependent but it's nonetheless interesting as we'll see. Here is an explanation of what I'm doing. We start with a digit \(d\) between 0 and 9 and any integer \(s\) that does not contain \(d\). For example, \(d=1\) and \(s=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. A formal definition follows.

Formal Definition of the Digit-Restricted Fibonacci Sequence


Let $d\in\{0,1,2,\dots,9\}$ denote the restricted initial digit, and let $s\in\mathbb{Z}$ denote the arbitrary second initial term. We define a sequence $(a_n)_{n=0}^{\infty}$ generated by a modified second-order linear recurrence, subject to a nonlinear digit-deletion operator.

First, we define the digit-deletion function $\Phi_d:\mathbb{Z}\to\mathbb{Z}$. For any integer $x$, let the absolute value $|x|$ be represented in base-10 as a sequence of digits $C=c_kc_{k-1}\dots c_0$, where $c_i\in\{0,1,\dots,9\}$. Let $C'$ be the subsequence of digits obtained by removing all instances of the forbidden digit $d$ from $C$. The function is defined as:

$$\Phi_d(x)=\begin{cases}0&\text{if }C'\text{ is the empty string},\\\text{sgn}(x)\cdot\text{val}(C')&\text{otherwise},\end{cases}$$

where $\text{sgn}(x)$ represents the sign of $x$, and $\text{val}(C')$ represents the standard base-10 numerical evaluation of the concatenated digit string $C'$.

The sequence $(a_n)$ is then defined recursively by the following initial conditions and recurrence relation:

$$\begin{aligned}a_0&=d,\\a_1&=s,\\a_n&=\Phi_d(a_{n-1}+a_{n-2})\quad\text{for }n\ge 2.\end{aligned}$$


Termination Criteria


To algorithmically generate a finite subsequence
$(a_n)_{n=0}^{N}$, we impose an upper bound constraint $M\in\mathbb{Z}^+$ (with a default of $M=40000$) and a period-detection mechanism. Sequence generation terminates at the index $N$ if either of the following conditions is satisfied:
  1. Threshold Exceedance: The absolute value of the sequence term exceeds the designated maximum bound, such that:

    $$|a_N|>M$$
  2. Loop Detection (Periodicity): The sequence enters a continuous cycle. Because $a_n$ is strictly dependent on the preceding pair $(a_{n-1},a_{n-2})$, periodicity is guaranteed if any consecutive pair repeats. The sequence terminates if there exists an index $k$ such that $1\le k<N-1$ satisfying:

    $$(a_{k-1},a_k)=(a_{N-1},a_N)$$

Upon meeting either termination criterion, the resulting finite sequence $(a_0,a_1,\dots,a_N)$ is yielded.

Figure 1 was the final output which did exactly what I wanted using a "forbidden number" of 1 (thus \(d=1\) ) and a second number of 2 (thus \(s=2\) ). The 34 term sequence generated enters a loop once the terms 5 and 5 are reached with a highest value of 9:

1, 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


Figure 1: permalink

Let's retain 1 as our "forbidden number" (thus \(d=1\) ) and use 24 as the second number (thus \(s=24\) ). Figure 2 shows the result. The 134 term sequence that generated enters a loop once the terms 2 and 8 are reached with a highest value of 98:

1, 24, 25, 49, 74, 23, 97, 20, 7, 27, 34, 6, 40, 46, 86, 32, 8, 40, 48, 88, 36, 24, 60, 84, 44, 28, 72, 0, 72, 72, 44, 6, 50, 56, 6, 62, 68, 30, 98, 28, 26, 54, 80, 34, 4, 38, 42, 80, 22, 2, 24, 26, 50, 76, 26, 2, 28, 30, 58, 88, 46, 34, 80, 4, 84, 88, 72, 60, 32, 92, 24, 6, 30, 36, 66, 2, 68, 70, 38, 8, 46, 54, 0, 54, 54, 8, 62, 70, 32, 2, 34, 36, 70, 6, 76, 82, 58, 40, 98, 38, 36, 74, 0, 74, 74, 48, 22, 70, 92, 62, 54, 6, 60, 66, 26, 92, 8, 0, 8, 8, 6, 4, 0, 4, 4, 8, 2, 0, 2, 2, 4, 6, 0, 6, 6, 2, 8


Figure 2: permalink

This is a rather more interesting graph but the numbers eventually enter a loop. Every time a number exceeds 100, it ends up back under 100. For example:

  • 1, 24, 25, 49, 74, 123 and the 123 becomes 23
  • 23, 97, 120 and the 120 becomes 20
The result is that the maximum value that this 137 term sequence reaches is 98. Let's try 70 as our second number (thus \(d=1\) and \(s=70\) ). Figure 3 shows the result. The resulting 171 term sequence enters a loop once 2 and 8 are reached with a maximum value of 98:

1, 70, 7, 77, 84, 6, 90, 96, 86, 82, 68, 50, 8, 58, 66, 24, 90, 4, 94, 98, 92, 90, 82, 72, 54, 26, 80, 6, 86, 92, 78, 70, 48, 8, 56, 64, 20, 84, 4, 88, 92, 80, 72, 52, 24, 76, 0, 76, 76, 52, 28, 80, 8, 88, 96, 84, 80, 64, 44, 8, 52, 60, 2, 62, 64, 26, 90, 6, 96, 2, 98, 0, 98, 98, 96, 94, 90, 84, 74, 58, 32, 90, 22, 2, 24, 26, 50, 76, 26, 2, 28, 30, 58, 88, 46, 34, 80, 4, 84, 88, 72, 60, 32, 92, 24, 6, 30, 36, 66, 2, 68, 70, 38, 8, 46, 54, 0, 54, 54, 8, 62, 70, 32, 2, 34, 36, 70, 6, 76, 82, 58, 40, 98, 38, 36, 74, 0, 74, 74, 48, 22, 70, 92, 62, 54, 6, 60, 66, 26, 92, 8, 0, 8, 8, 6, 4, 0, 4, 4, 8, 2, 0, 2, 2, 4, 6, 0, 6, 6, 2, 8


Figure 3: permalink

Though this sequence of 171 terms oscillates wildly, it still only reaches a maximum value of 98 before eventually looping. With a forbidden digit of 1 (\(d=1\)) and a starting number that is below 100 (\(s<100\)), no sequence member can exceed 100 and so the sequence must eventually loop.

There's lots to explore here and I'll do that in subsequent posts but that's enough for now. Below the SageMath code is included for completeness.

Updated Python / SageMath Implementation

Python
import matplotlib.pyplot as plt

def custom_fibonacci(forbidden_digit, second_num, max_val=40000):
    """
    Generates a modified Fibonacci sequence where the starting digit is forbidden 
    from appearing in any subsequent terms.
    """
    if not (0 <= forbidden_digit <= 9):
        raise ValueError("The first entry must be a single digit from 0 to 9.")

    sequence = [forbidden_digit, second_num]
    seen_pairs = set()
    seen_pairs.add((forbidden_digit, second_num))
    
    forbidden_str = str(forbidden_digit)
    entered_loop = False

    while True:
        raw_sum = sequence[-2] + sequence[-1]
        sum_str = str(raw_sum)
        filtered_str = sum_str.replace(forbidden_str, '')
        
        if filtered_str == '' or filtered_str == '-':
            next_term = 0
        else:
            next_term = int(filtered_str)
            
        if next_term > max_val:
            break
            
        current_pair = (sequence[-1], next_term)
        if current_pair in seen_pairs:
            entered_loop = True
            break
            
        sequence.append(next_term)
        seen_pairs.add(current_pair)

    return sequence, entered_loop

def plot_trajectory(sequence, forbidden_digit, second_num):
    """
    Plots the sequence trajectory with thin black lines, small black circles,
    and dynamic headroom to prevent annotation overlap with the title.
    """
    plt.figure(figsize=(12, 6))
    
    # Plot with thin black lines and small black circles
    plt.plot(sequence, color='black', marker='o', markersize=4, linewidth=1, linestyle='-')
    
    # Find and annotate the maximum value
    max_val = max(sequence)
    max_index = sequence.index(max_val)
    
    # Dynamically expand the y-axis to create headroom for the annotation
    plt.ylim(bottom=min(sequence) - (max_val * 0.05), top=max_val * 1.15)
    
    plt.annotate(f'Max Value Reached: {max_val}', 
                 xy=(max_index, max_val), 
                 xytext=(0, 15), # Offsets the text 15 points above the point
                 textcoords='offset points',
                 ha='center', 
                 va='bottom',
                 bbox=dict(boxstyle='round,pad=0.3', fc='white', ec='gray', lw=0.5),
                 arrowprops=dict(arrowstyle='->', connectionstyle='arc3,rad=0', color='black'))

    # Formatting the graph with added title padding
    plt.title(f"Modified Fibonacci Trajectory\nForbidden Digit: {forbidden_digit} 
| Starting Number: {second_num}", pad=20)
    plt.xlabel("Sequence Index (Term Number)")
    plt.ylabel("Value")
    plt.grid(True, linestyle='--', alpha=0.5)
    
    plt.tight_layout()
    plt.show()

# --- Execution and Display ---

digit_1 = 1
digit_2 = 2
max_limit = 40000

result_sequence, is_loop = custom_fibonacci(digit_1, digit_2, max_val=max_limit)

# 1. Print Text Output First
print(f"Starting Parameters: Forbidden Digit = {digit_1}, Second Number = {digit_2}")
print(f"Max Value Limit: {max_limit}")
print("-" * 50)
print(f"Resulting Sequence ({len(result_sequence)} terms):")
print(result_sequence)
print("-" * 50)

if is_loop:
    print("Conclusion: The sequence entered a continuous loop.")
    print(f"The repeating pair that triggered the stop was: 
({result_sequence[-2]}, {result_sequence[-1]})")
else:
    print(f"Conclusion: The sequence stopped because a term exceeded {max_limit}.")

# 2. Render Graph Below
plot_trajectory(result_sequence, digit_1, digit_2)