login
A022488
Describe previous term from the right (method B - initial term is 2).
9
2, 21, 1121, 112112, 21122112, 2112221221, 112211231221, 1122113121122212, 21112312211131122212, 211123123113221131211321, 112131122111311222311231211131211321, 112131122111311321113121123123123113221231112112
OFFSET
1,1
COMMENTS
Method B = 'digit'-indication followed by 'frequency'.
LINKS
Reinhard Zumkeller, Table of n, a(n) for n = 1..22
EXAMPLE
E.g., the term after 1121 is obtained by saying "1 once, 2 once, 1 twice", which gives 112112.
MATHEMATICA
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 *)
PROG
(Haskell)
import Data.List (group, transpose)
a022488 n = a022488_list !! (n-1)
a022488_list = 2 : f [2] :: [Integer] where
f xs = (read $ concatMap show ys) : f ys where
ys = concat $ transpose [map head zss, map length zss]
zss = reverse $ group xs
-- Reinhard Zumkeller, Apr 14 2014
(Python)
from re import split
A022488_list, l = [2], '2'
for _ in range(10):
....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 != '')
....A022488_list.append(int(l)) # Chai Wah Wu, Jan 07 2015
(Python)
from itertools import accumulate, groupby, repeat
def summarize(n, _):
return int("".join(k+str(len(list(g))) for k, g in groupby(str(n)[::-1])))
def aupton(nn): return list(accumulate(repeat(2, nn), summarize))
print(aupton(12)) # Michael S. Branicky, Feb 21 2021
KEYWORD
nonn,base,easy,nice
STATUS
approved