cp's OEIS Frontend

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.

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

This page as a plain text file.
%I A045918 #46 Feb 16 2025 08:32:38
%S A045918 10,11,12,13,14,15,16,17,18,19,1110,21,1112,1113,1114,1115,1116,1117,
%T A045918 1118,1119,1210,1211,22,1213,1214,1215,1216,1217,1218,1219,1310,1311,
%U A045918 1312,23,1314,1315,1316,1317,1318,1319,1410,1411,1412,1413,24,1415,1416,1417
%N A045918 Describe n. Also called the "Say What You See" or "Look and Say" sequence LS(n).
%C A045918 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 A045918 A121993 gives numbers m such that a(m) < m. - _Reinhard Zumkeller_, Jan 25 2014
%D A045918 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 A045918 Reinhard Zumkeller, <a href="/A045918/b045918.txt">Table of n, a(n) for n = 0..10000</a>
%H A045918 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 A045918 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 A045918 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/LookandSaySequence.html">Look and Say Sequence</a>
%H A045918 Wikipedia, <a href="http://en.wikipedia.org/wiki/Look-and-say_sequence">Look-and-say sequence</a>
%e A045918 23 has "one 2, one 3", so a(23) = 1213.
%p A045918 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 A045918 LookAndSayA[n_]  := FromDigits@ Flatten@ IntegerDigits@ Flatten[ Through[{Length, First}[#]] & /@ Split@ IntegerDigits@ n] (* _Robert G. Wilson v_, Jan 27 2012 *)
%o A045918 (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 A045918 (Haskell) -- see Watkins link, p. 3.
%o A045918 import Data.List (unfoldr, group); import Data.Tuple (swap)
%o A045918 a045918 0 = 10
%o A045918 a045918 n = foldl (\v d -> 10 * v + d) 0 $ say $ reverse $ unfoldr
%o A045918    (\x -> if x == 0 then Nothing else Just $ swap $ divMod x 10) n
%o A045918    where say = concat . map code . group
%o A045918          code xs = [toInteger $ length xs, head xs]
%o A045918 -- _Reinhard Zumkeller_, Aug 09 2012
%o A045918 (Python)
%o A045918 from re import finditer
%o A045918 def A045918(n):
%o A045918     return int(''.join([str(len(m.group(0)))+m.group(0)[0] for m in finditer(r'(\d)\1*',str(n))]))
%o A045918 # _Chai Wah Wu_, Dec 03 2014
%o A045918 (Python)
%o A045918 from itertools import groupby
%o A045918 def LS(n): return int(''.join(str(len(list(g)))+k for k, g in groupby(str(n))))
%o A045918 print([LS(n) for n in range(48)]) # _Michael S. Branicky_, Jul 27 2022
%Y A045918 Cf. A005150. See also A056815.
%K A045918 nonn,base
%O A045918 0,1
%A A045918 _N. J. A. Sloane_
%E A045918 Added Mma program from A056815. - _N. J. A. Sloane_, Feb 02 2012