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

24 Solutions

18 Solvers

Last Solution submitted on Dec 16, 2025

Last 200 Solutions

Problem Comments

Solution Comments

Show comments
Loading...

Problem Recent Solvers18

Suggested Problems

More from this Author321

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!