$ jq -n -r -f Self_referential_sequence.jq The maximal length to convergence for seeds up to 1000000 is 21. The corresponding seeds are the allowed permutations of the representative number(s): 9900 For each representative seed, the self-referential sequence is as follows: Representative: 9900 Self-referential sequence: [ 9900, 2920, 192210, 19222110, 19323110, 1923123110, 1923224110, 191413323110, 191433125110, 19151423125110, 19251413226110, 1916151413325110, 1916251423127110, 191716151413326100, 191726151423128100, 19181716151413326000, 19182716151423128000, 29181716151413330000, 19281716151423230000, 19281716151413430000, 19182716152413230000 ]