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).

Original entry on oeis.org

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

Views

Author

Keywords

Comments

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
A121993 gives numbers m such that a(m) < m. - Reinhard Zumkeller, Jan 25 2014

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.

Crossrefs

Cf. A005150. See also A056815.

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