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
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 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,1
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
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
Eric Weisstein's World of Mathematics, Look and Say Sequence
EXAMPLE
23 has "one 2, one 3", so a(23) = 1213.
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 *)
PROG
(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
(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
(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
CROSSREFS
Cf. A005150. See also A056815.
Sequence in context: A047842 A047843 A097598 * A244112 A088476 A248014
KEYWORD
nonn,base
AUTHOR
EXTENSIONS
Added Mma program from A056815. - N. J. A. Sloane, Feb 02 2012
STATUS
approved

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 28 06:27 EDT 2024. Contains 372020 sequences. (Running on oeis4.)