A045918 Describe n. Also called the "Say What You See" or "Look and Say" sequence LS(n).
10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1110, 21, 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1119, 1210, 1211, 22, 1213, 1214, 1215, 1216, 1217, 1218, 1219, 1310, 1311, 1312, 23, 1314, 1315, 1316, 1317, 1318, 1319, 1410, 1411, 1412, 1413, 24, 1415, 1416, 1417
Offset: 0
Examples
23 has "one 2, one 3", so a(23) = 1213.
References
- J. H. Conway, The weird and wonderful chemistry of audioactive decay, in T. M. Cover and Gopinath, eds., Open Problems in Communication and Computation, Springer, NY 1987, pp. 173-188.
Links
- Reinhard Zumkeller, Table of n, a(n) for n = 0..10000
- Kevin Watkins, Abstract Interpretation Using Laziness: Proving Conway's Lost Cosmological Theorem,
- Kevin Watkins, Proving Conway's Lost Cosmological Theorem, POP seminar talk, CMU, Dec 2006
- Eric Weisstein's World of Mathematics, Look and Say Sequence
- Wikipedia, Look-and-say sequence
Programs
-
Haskell
-- see Watkins link, p. 3. import Data.List (unfoldr, group); import Data.Tuple (swap) a045918 0 = 10 a045918 n = foldl (\v d -> 10 * v + d) 0 $ say $ reverse $ unfoldr (\x -> if x == 0 then Nothing else Just $ swap $ divMod x 10) n where say = concat . map code . group code xs = [toInteger $ length xs, head xs] -- Reinhard Zumkeller, Aug 09 2012
-
Maple
LS:=n-> if n>9 then LS(op(convert(n,base,10))) else for i from 2 to nargs do if args[i] <> n then RETURN(( LS( args[i..nargs] )*10^length(i-1) + i-1)*10 + n ) fi od: 10*nargs + n fi; # M. F. Hasler, Nov 14 2006
-
Mathematica
LookAndSayA[n_] := FromDigits@ Flatten@ IntegerDigits@ Flatten[ Through[{Length, First}[#]] & /@ Split@ IntegerDigits@ n] (* Robert G. Wilson v, Jan 27 2012 *)
-
PARI
A045918(a)={my(c=1);for(j=2,#a=Vec(Str(a)),if(a[j-1]==a[j],a[j-1]="";c++,a[j-1]=Str(c,a[j-1]);c=1));a[#a]=Str(c,a[#a]);eval(concat(a))} \\ M. F. Hasler, Jan 27 2012
-
Python
from re import finditer def A045918(n): return int(''.join([str(len(m.group(0)))+m.group(0)[0] for m in finditer(r'(\d)\1*',str(n))])) # Chai Wah Wu, Dec 03 2014
-
Python
from itertools import groupby def LS(n): return int(''.join(str(len(list(g)))+k for k, g in groupby(str(n)))) print([LS(n) for n in range(48)]) # Michael S. Branicky, Jul 27 2022
Extensions
Added Mma program from A056815. - N. J. A. Sloane, Feb 02 2012
Comments