
EXAMPLE

This sequence consists of those terms of A071158 for which the first factorial digit is equal to the number of 1's in the term and the following algorithm results the remaining factorial digits of the same term: First, extract all maximal subsequences from the term (for d ranging from 1 to the largest digit present) that consist of digits d and d+1 and place them next to each other, from left to right. E.g. for the term 2354543212221 this yields the sequence: 2212221,2332222,3443,5454,55. After discarding the last digit (here 5) and replacing in each batch the smaller number with +1 and larger number with 1, we get:
1,1,+1,1,1,1,+1,+1,1,1,+1,+1,+1,+1,+1,1,1,+1,1,+1,1,+1,+1.
and summing these from RIGHT, we get the following partial sums:
1, 2, 3, 2, 3, 4, 5, 4, 3, 4, 5, 4, 3, 2, 1, 0, 1, 2, 1, 2, 1, 2, 1.
Retaining only the partial sums under the +1's (i.e. the rightmost one and all the partial sums that are larger than the preceding partial sum one step to the right) we obtain: 3,5,4,5,4,3,2,1,2,2,2 and 1. These, after appended to the number of 1's in the original term (2), yields the same term 2354543212221 from which we started from, which thus is a member of this sequence. Similarly, the term 2432211 belongs to this sequence, because the same procedure yields:
22211,2322,43,4 and after discarding the last 4:
1,1,1,+1,+1,+1,1,+1,+1,1,+1 and summing from the right:
1, 2, 3, 4, 3, 2, 1, 2, 1, 0, 1.
collecting all the partial sums larger than their right neighbor (those under +1's), which appended after the number of 1's (2), results the same term 2432211.
