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.

No comments:

Post a Comment