Problem 57535. Find patterns in subprime Fibonacci sequences
Lots of Cody problems involve Fibonacci and Collatz sequences. Fibonacci sequences start with two numbers, and later terms are computed by summing the previous two terms. The terms continue to increase, of course. Terms in Collatz sequences are computed with a different formula, and for the initial values that have been tried, the sequences eventually reach a 1. An unsolved problem is whether Collatz sequences reach 1 for any initial value.
The problem combines ideas from these two sequences by examining subprime Fibonacci sequences. The sequence starts with two given values, and the next term is computed as the sum of the previous two. However, if the sum is composite, it is divided by the smallest prime factor. If the starting values are [1 1], then the sequence is 1, 1, 2, 3, 5, 4, 3, 7, 5, etc.
Just as all Collatz sequences reach 1 (so far), all subprime Fibonacci sequences reach a repeating pattern. However, the pattern changes with the starting values. With starting values [1 1], the repeating pattern is 18 terms long, and it starts on term 38. With starting values [7 37], the repeating pattern is 136 terms long, and it starts on term 37. The subprime Fibonacci conjecture, from this paper, is that a repeating pattern is reached for all starting values.
Write a function that takes a vector of two starting values and produces the repeating pattern, the number of the starting term, and the length of the pattern. Can you find patterns of lengths other than those in the test suite? Can you prove the subprime Fibonacci conjecture?
Solution Stats
Problem Comments
-
3 Comments
William
on 12 Jan 2023
All the tests except #2 have a curious notation for the value of q_correct, and it is undefined.
Ramon Villamangca
on 12 Jan 2023
Unrecognized function or variable 'q18'.
ChrisR
on 12 Jan 2023
Sorry. It should work now.
I tried defining the patterns at the top of the code, and I should have known that Cody would strip that code away. It happened in just about every problem in the MATLAB Fundamentals - Plotting and Visualization group.
Solution Comments
Show commentsProblem Recent Solvers3
Suggested Problems
-
2598 Solvers
-
2457 Solvers
-
given 3 sides, find area of this triangle
798 Solvers
-
Find the sum of the elements in the "second" diagonal
1149 Solvers
-
103 Solvers
More from this Author281
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!