This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A022488 #28 Dec 02 2024 16:54:05 %S A022488 2,21,1121,112112,21122112,2112221221,112211231221,1122113121122212, %T A022488 21112312211131122212,211123123113221131211321, %U A022488 112131122111311222311231211131211321,112131122111311321113121123123123113221231112112 %N A022488 Describe previous term from the right (method B - initial term is 2). %C A022488 Method B = 'digit'-indication followed by 'frequency'. %H A022488 Reinhard Zumkeller, <a href="/A022488/b022488.txt">Table of n, a(n) for n = 1..22</a> %e A022488 E.g., the term after 1121 is obtained by saying "1 once, 2 once, 1 twice", which gives 112112. %t A022488 A022488[1]:=2;A022488[n_]:=A022488[n]=FromDigits[Flatten[{First[#],Length[#]}&/@Split[Reverse[IntegerDigits[A022488[n-1]]]]]];Map[A022488,Range[15]] (* _Peter J. C. Moses_, Apr 22 2013 *) %o A022488 (Haskell) %o A022488 import Data.List (group, transpose) %o A022488 a022488 n = a022488_list !! (n-1) %o A022488 a022488_list = 2 : f [2] :: [Integer] where %o A022488 f xs = (read $ concatMap show ys) : f ys where %o A022488 ys = concat $ transpose [map head zss, map length zss] %o A022488 zss = reverse $ group xs %o A022488 -- _Reinhard Zumkeller_, Apr 14 2014 %o A022488 (Python) %o A022488 from re import split %o A022488 A022488_list, l = [2], '2' %o A022488 for _ in range(10): %o A022488 l = ''.join(d[0]+str(len(d)) for d in split('(0+|1+|2+|3+|4+|5+|6+|7+|8+|9+)',l[::-1]) if d != '') %o A022488 A022488_list.append(int(l)) # _Chai Wah Wu_, Jan 07 2015 %o A022488 (Python) %o A022488 from itertools import accumulate, groupby, repeat %o A022488 def summarize(n, _): %o A022488 return int("".join(k+str(len(list(g))) for k, g in groupby(str(n)[::-1]))) %o A022488 def aupton(nn): return list(accumulate(repeat(2, nn), summarize)) %o A022488 print(aupton(12)) # _Michael S. Branicky_, Feb 21 2021 %Y A022488 Cf. A022481, A022514, A022515, A022516, A022517, A022518, A022519, A022520. %K A022488 nonn,base,easy,nice %O A022488 1,1 %A A022488 _Clark Kimberling_