login
A022512
Describe previous term from the right (method A - initial term is 8).
2
8, 18, 1811, 211811, 21182112, 122112182112, 122112181112212211, 2122112231181112212211, 21221122311821132221221112, 12312211321321121821132221221112
OFFSET
0,1
COMMENTS
Method A = 'frequency' followed by 'digit'-indication.
EXAMPLE
E.g., the term after 1811 is obtained by saying "two 1's, one 8, one 1", which gives 211811.
MATHEMATICA
split[n_]:=Split[Reverse[IntegerDigits[n]]];
list1[n_]:=List/@Length/@split[n]; riffle1[n_]:=Riffle[split[n], list1[n]];
tab[n_]:=Table[i, {i, 1, 2*Length[list1[n]], 2}];
list2[n_]:=Append[riffle1[n][[#]], riffle1[n][[#+1]]]&/@tab[n];
flat[n_]:=Flatten/@list2[n]; riffle2[n_]:=Riffle[Last/@flat[n], First/@flat[n]];
a[1]=8; a[n_]:=FromDigits[riffle2[a[n-1]]]; Array[a, 10] (* or *)
IntegerReverse[NestList[FromDigits[Flatten[Replace[Replace[Replace[Split[Reverse[IntegerDigits[#]]], {x_, y_}->{x, Length[{x, y}]}, {1}], {x_, y_, z_}->{x, Length[{x, y, z}]}, {1}], {x_}->{x, Length[{x}]}, {1}]]]&, 8, 9]] (* Ivan N. Ianakiev, Nov 10 2016 *)
CROSSREFS
KEYWORD
nonn,base,easy,nice
EXTENSIONS
More terms from Erich Friedman
STATUS
approved