Cody Problem 46122 involved a counting sequence that I called the digit inventory sequence, in which each term provides an inventory of the digits of the previous term. If the initial number of the sequence is 24, then the sequence is
24, 1214, 211214, 312214, 21221314, 31321314, 31123314, 31123314, ...
For example, the third term provides an inventory of the second: two 1's, one 2, one 4. Notice that starting with 24 leads to a steady state after 7 terms because all subsequent terms are equal to the seventh (i.e., 31123314).
However, the final state is not necessarily a steady state. If the starting number is 210, then the sequence is
210, 101112, 104112, 10311214, 1041121314, 1051121324, 104122131415, 105122132415,
104132131425, 104122232415, 103142132415, 104122232415, 103142132415, ...
The tenth and eleventh terms repeat indefinitely. In other words, the repeated terms start at term 10, and they have a period of 2.
Write a function to determine the number of the term at which the final state begins and the period of the repeated terms.
Solution Stats
Problem Comments
5 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers18
Suggested Problems
-
2522 Solvers
-
2537 Solvers
-
Sum all integers from 1 to 2^n
17386 Solvers
-
Pernicious Anniversary Problem
835 Solvers
-
59 Solvers
More from this Author321
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
Rats. My solution got all the problems right except the last. How is that possible?
William, our results differ for a starting value of 570. I'm not sure why yet.
William, I think I see the reason for the difference now. Let me know if you want a hint.
Aha! I see the problem with 570. Very clever of you to include a case like that!
Thanks but I'd say I was more lucky than clever. A run of periods drew me to that range. You're right that the case of 570 is a good one.