login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A045918 Describe n. Also called the "Say What You See" or "Look and Say" sequence LS(n). 55

%I #42 Jul 27 2022 02:44:23

%S 10,11,12,13,14,15,16,17,18,19,1110,21,1112,1113,1114,1115,1116,1117,

%T 1118,1119,1210,1211,22,1213,1214,1215,1216,1217,1218,1219,1310,1311,

%U 1312,23,1314,1315,1316,1317,1318,1319,1410,1411,1412,1413,24,1415,1416,1417

%N Describe n. Also called the "Say What You See" or "Look and Say" sequence LS(n).

%C a(1111111111) = a((10^10 - 1)/9) = 101 is the first term with an odd number of digits; 3-digit terms are unambiguous, but already the 2nd 4-digit term is LS( 12 ) = 1112 = LS( 2*(10^111-1)/9 ) ("hundred eleven 2's"). The smallest n such that LS(n) = LS(k) for some k < n (i.e. the largest n such that the restriction of LS to [0..n-1] is injective) appears to be 10*(10^11 - 1)/9 : LS(eleven '1's, one '0') = 11110 = LS(one '1', eleven '0's). - _M. F. Hasler_, Nov 14 2006

%C A121993 gives numbers m such that a(m) < m. - _Reinhard Zumkeller_, Jan 25 2014

%D 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.

%H Reinhard Zumkeller, <a href="/A045918/b045918.txt">Table of n, a(n) for n = 0..10000</a>

%H Kevin Watkins, <a href="http://www.cs.cmu.edu/~kw/pubs/conway.pdf">Abstract Interpretation Using Laziness: Proving Conway's Lost Cosmological Theorem, </a>

%H Kevin Watkins, <a href="http://www.cs.cmu.edu/~kw/pubs/conwayslides.pdf">Proving Conway's Lost Cosmological Theorem, POP seminar talk, CMU, Dec 2006</a>

%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/LookandSaySequence.html">Look and Say Sequence</a>

%H Wikipedia, <a href="http://en.wikipedia.org/wiki/Look-and-say_sequence">Look-and-say sequence</a>

%e 23 has "one 2, one 3", so a(23) = 1213.

%p 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

%t LookAndSayA[n_] := FromDigits@ Flatten@ IntegerDigits@ Flatten[ Through[{Length, First}[#]] & /@ Split@ IntegerDigits@ n] (* _Robert G. Wilson v_, Jan 27 2012 *)

%o (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

%o (Haskell) see Watkins link, p. 3.

%o import Data.List (unfoldr, group); import Data.Tuple (swap)

%o a045918 0 = 10

%o a045918 n = foldl (\v d -> 10 * v + d) 0 $ say $ reverse $ unfoldr

%o (\x -> if x == 0 then Nothing else Just $ swap $ divMod x 10) n

%o where say = concat . map code . group

%o code xs = [toInteger $ length xs, head xs]

%o -- _Reinhard Zumkeller_, Aug 09 2012

%o (Python)

%o from re import finditer

%o def A045918(n):

%o return int(''.join([str(len(m.group(0)))+m.group(0)[0] for m in finditer(r'(\d)\1*',str(n))]))

%o # _Chai Wah Wu_, Dec 03 2014

%o (Python)

%o from itertools import groupby

%o def LS(n): return int(''.join(str(len(list(g)))+k for k, g in groupby(str(n))))

%o print([LS(n) for n in range(48)]) # _Michael S. Branicky_, Jul 27 2022

%Y Cf. A005150. See also A056815.

%K nonn,base

%O 0,1

%A _N. J. A. Sloane_

%E Added Mma program from A056815. - _N. J. A. Sloane_, Feb 02 2012

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 20 09:04 EDT 2024. Contains 371799 sequences. (Running on oeis4.)