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.

A005150 Look and Say sequence: describe the previous term! (method A - initial term is 1).

This page as a plain text file.
%I A005150 M4780 #293 Jun 11 2025 00:16:51
%S A005150 1,11,21,1211,111221,312211,13112221,1113213211,31131211131221,
%T A005150 13211311123113112211,11131221133112132113212221,
%U A005150 3113112221232112111312211312113211,1321132132111213122112311311222113111221131221,11131221131211131231121113112221121321132132211331222113112211,311311222113111231131112132112311321322112111312211312111322212311322113212221
%N A005150 Look and Say sequence: describe the previous term! (method A - initial term is 1).
%C A005150 Method A = "frequency" followed by "digit"-indication.
%C A005150 Also known as the "Say What You See" sequence.
%C A005150 Only the digits 1, 2 and 3 appear in any term. - _Robert G. Wilson v_, Jan 22 2004
%C A005150 All terms end with 1 (the seed) and, except the third a(3), begin with 1 or 3. - _Jean-Christophe Hervé_, May 07 2013
%C A005150 Proof that 333 never appears in any a(n): suppose it appears for the first time in a(n); because of "three 3" in 333, it would imply that 333 is also in a(n-1), which is a contradiction. - _Jean-Christophe Hervé_, May 09 2013
%C A005150 This sequence is called "suite de Conway" in French (see Wikipédia link). - _Bernard Schott_, Jan 10 2021
%C A005150 Contrary to many accounts (including an earlier comment on this page), Conway did not invent the sequence. The first mention of the sequence appears to date back to the 1977 International Mathematical Olympiad in Belgrade, Yugoslavia. See the Editor's note on page 4, directly preceding Conway's article in Eureka referenced below. - _Harlan J. Brothers_, May 03 2024
%D A005150 John H. Conway and Richard K. Guy, The Book of Numbers, New York: Springer-Verlag, 1996. See p. 208.
%D A005150 S. R. Finch, Mathematical Constants, Cambridge, 2003, section 6.12 Conway's Constant, pp. 452-455.
%D A005150 M. Gilpin, On the generalized Gleichniszahlen-Reihe sequence, Manuscript, Jul 05 1994.
%D A005150 A. Lakhtakia and C. Pickover, Observations on the Gleichniszahlen-Reihe: An Unusual Number Theory Sequence, J. Recreational Math., 25 (No. 3, 1993), 192-198.
%D A005150 Clifford A. Pickover, Computers and the Imagination, St Martin's Press, NY, 1991.
%D A005150 Clifford A. Pickover, Fractal horizons: the future use of fractals, New York: St. Martin's Press, 1996. ISBN 0312125992. Chapter 7 has an extensive description of the elements and their properties.
%D A005150 C. A. Pickover, The Math Book, Sterling, NY, 2009; see p. 486.
%D A005150 N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
%D A005150 James J. Tattersall, Elementary Number Theory in Nine Chapters, 1999, p. 23.
%D A005150 I. Vardi, Computational Recreations in Mathematica. Addison-Wesley, Redwood City, CA, 1991, p. 4.
%H A005150 T. D. Noe, <a href="/A005150/b005150.txt">Table of n, a(n) for n = 1..25</a>
%H A005150 Henry Bottomley, <a href="http://www.se16.info/js/lands2.htm">Evolution of Conway's 92 Look and Say audioactive elements</a>.
%H A005150 Éric Brier, Rémi Géraud-Stewart, David Naccache, Alessandro Pacco, and Emanuele Troiani, <a href="https://arxiv.org/abs/2006.06837">Stuttering Conway Sequences Are Still Conway Sequences</a>, arXiv:2006.06837 [math.DS], 2020.
%H A005150 Éric Brier, Rémi Géraud-Stewart, David Naccache, Alessandro Pacco, and Emanuele Troiani, <a href="https://arxiv.org/abs/2006.07246">The Look-and-Say The Biggest Sequence Eventually Cycles</a>, arXiv:2006.07246 [math.DS], 2020.
%H A005150 Onno M. Cain and Sela T. Enin, <a href="https://arxiv.org/abs/2004.00209">Inventory Loops (i.e. Counting Sequences) have Pre-period 2 max S_1 + 60</a>, arXiv:2004.00209 [math.NT], 2020.
%H A005150 Ben Chen, Richard Chen, Joshua Guo, Tanya Khovanova, Shane Lee, Neil Malur, Nastia Polina, Poonam Sahoo, Anuj Sakarda, Nathan Sheffield, and Armaan Tipirneni, <a href="https://arxiv.org/abs/1808.04199">On Base 3/2 and its Sequences</a>, arXiv:1808.04304 [math.NT], 2018.
%H A005150 J. H. Conway, <a href="https://static01.nyt.com/packages/pdf/crossword/GENIUS_AT_PLAY_Eureka_Article.pdf">The weird and wonderful chemistry of audioactive decay</a>, Eureka 46 (1986) 5-16.
%H A005150 J. H. Conway, <a href="http://dx.doi.org/10.1007/978-1-4612-4808-8_53">The weird and wonderful chemistry of audioactive decay</a>, in T. M. Cover and Gopinath, eds., Open Problems in Communication and Computation, Springer, NY 1987, pp. 173-188.
%H A005150 J. H. Conway and Brady Haran, <a href="https://www.youtube.com/watch?v=ea7lJkEhytA">Look-and-Say Numbers</a> (2014), Numberphile video.
%H A005150 S. B. Ekhad and D. Zeilberger, <a href="https://arxiv.org/abs/math/9808077">Proof of Conway's Lost Cosmological Theorem</a>, arXiv:math/9808077 [math.CO], 1998.
%H A005150 S. B. Ekhad and D. Zeilberger, <a href="http://www.ams.org/era/1997-03-11/S1079-6762-97-00026-7/home.html">Proof of Conway's lost cosmological theorem</a>, Electron. Res. Announc. Amer. Math. Soc. 3 (1997), 78-82.
%H A005150 S. Eliahou and M. J. Erickson, <a href="https://doi.org/10.1016/j.disc.2012.11.014">Mutually describing multisets and integer partitions</a>, Discrete Mathematics, Volume 313, Issue 4, Feb 28 2013, Pages 422-433. - From _N. J. A. Sloane_, Jan 03 2013
%H A005150 S. R. Finch, <a href="http://web.archive.org/web/20010207194413 /http://www.mathsoft.com/asolve/constant/cnwy/cnwy.html">Conway's Constant</a> [From the Wayback Machine]
%H A005150 Steven Finch, <a href="https://doi.org/10.1007/s00283-021-10060-2">The On-Line Encyclopedia of Integer Sequences, founded in 1964 by N. J. A. Sloane</a>, A Tribute to John Horton Conway, The Mathematical Intelligencer (2021) Vol. 43, 146-147.
%H A005150 X. Gourdon and B. Salvy, <a href="https://doi.org/10.1016/0012-365X(95)00133-H">Effective asymptotics of linear recurrences with rational coefficients</a>, Discrete Mathematics, vol. 153, no. 1-3, 1996, pages 145-163. See p. 161.
%H A005150 M. Hilgemeier, <a href="/A005150/a005150_1.pdf">Die Gleichniszahlen-Reihe</a>, in Bild der Wissenschaft, 12 (1986), 194-195, with permission from the Konradin Medien GmbH.
%H A005150 M. Hilgemeier, <a href="http://www.se16.info/mhi/">One metaphor fits all</a>, in Fractal Horizons, ed. C. A Pickover, St. Martins, NY, 1996, pp. 137-161.
%H A005150 R. A. Litherland, <a href="/A005150/a005150.html">Conway's Cosmological Theorem (Overview)</a>.
%H A005150 R. A. Litherland, <a href="/A005150/a005150_3.pdf">Conway's Cosmological Theorem</a>, 12 pages, Apr 14 2006 (pdf file).
%H A005150 R. A. Litherland, <a href="/A005150/a005150.tar.gz">Programs for Conway's Cosmological Theorem</a>, (gzipped tar ball).
%H A005150 R. A. Litherland, <a href="/A005150/a005150_4.pdf">The audioactive package</a>.
%H A005150 M. Lothaire, <a href="http://www-igm.univ-mlv.fr/~berstel/Lothaire/">Algebraic Combinatorics on Words</a>, Cambridge, 2002, see p. 37, etc.
%H A005150 MacTutor History of Mathematics, <a href="https://mathshistory.st-andrews.ac.uk/Biographies/Conway/">John H. Conway</a>
%H A005150 O. Martin, <a href="http://www.jstor.org/stable/27641915">Look-and-Say Biochemistry: Exponential RNA and Multistranded DNA</a>, Amer. Math. Monthly, 113 (No. 4, 2006), 289-307. - From _N. J. A. Sloane_, Feb 19 2013
%H A005150 Thomas Morrill, <a href="https://arxiv.org/abs/2004.06414">Look, Knave</a>, arXiv:2004.06414 [math.CO], 2020.
%H A005150 Paulo Ortolan, <a href="/A005150/a005150.txt">Java program for A005150</a>.
%H A005150 Matt Parker, <a href="https://www.youtube.com/watch?v=EGoRJePORHs">Can you trust an elegant conjecture?</a>, Stand-Up Maths, 2022, video.
%H A005150 Rosetta Code, <a href="http://rosettacode.org/wiki/Look-and-say_sequence">Look and say sequence</a> programs in over 60 languages.
%H A005150 J. Sauerberg and L. Shu, <a href="http://www.jstor.org/stable/2974579">The long and the short on counting sequences</a>, Amer. Math. Monthly, 104 (1997), 306-317.
%H A005150 T. Sillke, <a href="http://www.mathematik.uni-bielefeld.de/~sillke/SEQUENCES/series000">Conway sequence</a>.
%H A005150 L. J. Upton, <a href="/A005151/a005151.pdf">Letter to N. J. A. Sloane</a>, Jan 08 1991.
%H A005150 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 A005150 Kevin Watkins, <a href="http://www.cs.cmu.edu/~kw/pubs/conwayslides.pdf">Proving Conway's Lost Cosmological Theorem</a>, POP seminar talk, CMU, Dec 2006.
%H A005150 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/LookandSaySequence.html">Look and Say Sequence</a>.
%H A005150 Wikipedia, <a href="http://en.wikipedia.org/wiki/Look-and-say_sequence">Look-and-say sequence</a>.
%H A005150 Wikipédia, <a href="https://fr.wikipedia.org/wiki/Suite_de_Conway">Suite de Conway</a>.
%H A005150 W. W. Zadrozny, <a href="https://arxiv.org/abs/2109.12755">Abstraction, Reasoning and Deep Learning: A Study of the "Look and Say" Sequence</a>, arXiv:2109.12755 [cs.AI], 2022.
%H A005150 Julia Witte Zimmerman, Denis Hudon, Kathryn Cramer, Jonathan St. Onge, Mikaela Fudolig, Milo Z. Trujillo, Christopher M. Danforth, and Peter Sheridan Dodds, <a href="https://arxiv.org/abs/2306.06794">A blind spot for large language models: Supradiegetic linguistic information</a>, arXiv:2306.06794 [cs.CL], 2023.
%H A005150 Julia Witte Zimmerman, Denis Hudon, Kathryn Cramer, Alejandro J. Ruiz, Calla Beauregard, Ashley Fehr, Mikaela Irene Fudolig, Bradford Demarest, Yoshi Meke Bird, Milo Z. Trujillo, Christopher M. Danforth, and Peter Sheridan Dodds, <a href="https://arxiv.org/abs/2412.10924">Tokens, the oft-overlooked appetizer: Large language models, the distributional hypothesis, and meaning</a>, arXiv:2412.10924 [cs.CL], 2024. See pp. 21, 28.
%F A005150 a(n+1) = A045918(a(n)). - _Reinhard Zumkeller_, Aug 09 2012
%F A005150 a(n) = Sum_{k=1..A005341(n)} A034002(n,k)*10^(A005341(n)-k). - _Reinhard Zumkeller_, Dec 15 2012
%F A005150 a(n) = A004086(A007651(n)). - _Bernard Schott_, Jan 08 2021
%F A005150 A055642(a(n+1)) = A005341(n+1) = 2*A043562(a(n)). - _Ya-Ping Lu_, Jan 28 2025
%F A005150 Conjecture: DC(a(n)) ~ k * (Conway's constant)^n where k is approximately 1.021... and DC denotes the number of digit changes in the decimal representation of n (e.g., DC(13112221)=4 because 1->3, 3-1, 1->2, 2->1). - _Bill McEachen_, May 09 2025
%F A005150 Conjecture: lim_{n->infinity} (c2+c3-c1)/(c1+c2+c3) = 0.01 approximately, where ci is the number of appearances of 'i' in a(n). - _Ya-Ping Lu_, Jun 05 2025
%e A005150 The term after 1211 is obtained by saying "one 1, one 2, two 1's", which gives 111221.
%t A005150 RunLengthEncode[ x_List ] := (Through[ {First, Length}[ #1 ] ] &) /@ Split[ x ]; LookAndSay[ n_, d_:1 ] := NestList[ Flatten[ Reverse /@ RunLengthEncode[ # ] ] &, {d}, n - 1 ]; F[ n_ ] := LookAndSay[ n, 1 ][ [ n ] ]; Table[ FromDigits[ F[ n ] ], {n, 1, 15} ]
%t A005150 A005150[1] := 1; A005150[n_] := A005150[n] = FromDigits[Flatten[{Length[#], First[#]}&/@Split[IntegerDigits[A005150[n-1]]]]]; Map[A005150, Range[25]] (* _Peter J. C. Moses_, Mar 21 2013 *)
%o A005150 (Haskell)
%o A005150 import List
%o A005150 say :: Integer -> Integer
%o A005150 say = read . concatMap saygroup . group . show
%o A005150 where saygroup s = (show $ length s) ++ [head s]
%o A005150 look_and_say :: [Integer]
%o A005150 look_and_say = 1 : map say look_and_say
%o A005150 -- Josh Triplett (josh(AT)freedesktop.org), Jan 03 2007
%o A005150 (Haskell)
%o A005150 a005150 = foldl1 (\v d -> 10 * v + d) . map toInteger . a034002_row
%o A005150 -- _Reinhard Zumkeller_, Aug 09 2012
%o A005150 (Java) See Paulo Ortolan link.
%o A005150 (Perl)
%o A005150 $str="1"; for (1 .. shift(@ARGV)) { print($str, ","); @a = split(//,$str); $str=""; $nd=shift(@a); while (defined($nd)) { $d=$nd; $cnt=0; while (defined($nd) && ($nd eq $d)) { $cnt++; $nd = shift(@a); } $str .= $cnt.$d; } } print($str);
%o A005150 # Jeff Quilici (jeff(AT)quilici.com), Aug 12 2003
%o A005150 (Perl)
%o A005150 # This outputs the first n elements of the sequence, where n is given on the command line.
%o A005150 $s = 1;
%o A005150 for (2..shift @ARGV) {
%o A005150 print "$s, ";
%o A005150 $s =~ s/(.)\1*/(length $&).$1/eg;
%o A005150 }
%o A005150 # Arne 'Timwi' Heizmann (timwi(AT)gmx.net), Mar 12 2008
%o A005150 print "$s\n";
%o A005150 (Python)
%o A005150 def A005150(n):
%o A005150     p = "1"
%o A005150     seq = [1]
%o A005150     while (n > 1):
%o A005150         q = ''
%o A005150         idx = 0 # Index
%o A005150         l = len(p) # Length
%o A005150         while idx < l:
%o A005150             start = idx
%o A005150             idx = idx + 1
%o A005150             while idx < l and p[idx] == p[start]:
%o A005150                 idx = idx + 1
%o A005150             q = q + str(idx-start) + p[start]
%o A005150         n, p = n - 1, q
%o A005150         seq.append(int(p))
%o A005150     return seq
%o A005150 # Olivier Mengue (dolmen(AT)users.sourceforge.net), Jul 01 2005
%o A005150 (Python)
%o A005150 def A005150(n):
%o A005150     seq = [1] + [None] * (n - 1) # allocate entire array space
%o A005150     def say(s):
%o A005150         acc = '' # initialize accumulator
%o A005150         while len(s) > 0:
%o A005150             i = 0
%o A005150             c = s[0] # char of first run
%o A005150             while (i < len(s) and s[i] == c): # scan first digit run
%o A005150                 i += 1
%o A005150             acc += str(i) + c # append description of first run
%o A005150             if i == len(s):
%o A005150                 break # done
%o A005150             else:
%o A005150                 s = s[i:] # trim leading run of digits
%o A005150         return acc
%o A005150     for i in range(1, n):
%o A005150         seq[i] = int(say(str(seq[i-1])))
%o A005150     return seq
%o A005150 # E. Johnson (ejohnso9(AT)earthlink.net), Mar 31 2008
%o A005150 (Python)
%o A005150 # program without string operations
%o A005150 def sign(n): return int(n > 0)
%o A005150 def say(a):
%o A005150     r = 0
%o A005150     p = 0
%o A005150     while a > 0:
%o A005150         c = 3 - sign((a % 100) % 11) - sign((a % 1000) % 111)
%o A005150         r += (10 * c + (a % 10)) * 10**(2*p)
%o A005150         a //= 10**c
%o A005150         p += 1
%o A005150     return r
%o A005150 a = 1
%o A005150 for i in range(1, 26):
%o A005150     print(i, a)
%o A005150     a = say(a)
%o A005150 # _Volker Diels-Grabsch_, Aug 18 2013
%o A005150 (Python)
%o A005150 import re
%o A005150 def lookandsay(limit, sequence = 1):
%o A005150     if limit > 1:
%o A005150         return lookandsay(limit-1, "".join([str(len(match.group()))+match.group()[0] for matchNum, match in enumerate(re.finditer(r"(\w)\1*", str(sequence)))]))
%o A005150     else:
%o A005150         return sequence
%o A005150 # lookandsay(3) --> 21
%o A005150 # _Nicola Vanoni_, Nov 29 2016
%o A005150 (Python)
%o A005150 import itertools
%o A005150 x = "1"
%o A005150 for i in range(20):
%o A005150     print(x)
%o A005150     x = ''.join(str(len(list(g)))+k for k,g in itertools.groupby(x))
%o A005150 # _Matthew Cotton_, Nov 12 2019
%o A005150 (PARI) A005150(n,a=1)={ while(n--, 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]); a=concat(a)); a }  \\ _M. F. Hasler_, Jun 30 2011
%Y A005150 Cf. A001155, A006751, A006715, A001140, A001141, A001143, A001145, A001151, A001154, A007651, A060857.
%Y A005150 Cf. A001387, Periodic table: A119566.
%Y A005150 Cf. A225224, A221646, A225212 (continuous versions).
%Y A005150 Apart from the first term, all terms are in A001637.
%Y A005150 About digits: A005341 (number of digits), A022466 (number of 1's), A022467 (number of 2's), A022468 (number of 3's), A004977 (sum of digits), A253677 (product of digits).
%Y A005150 About primes: A079562 (number of distinct prime factors), A100108 (terms that are primes), A334132 (smallest prime factor).
%Y A005150 Cf. A014715 (Conway's constant), A098097 (terms interpreted as written in base 4).
%K A005150 nonn,base,easy,nice
%O A005150 1,2
%A A005150 _N. J. A. Sloane_