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.

Showing 1-6 of 6 results.

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

Original entry on oeis.org

1, 11, 21, 1211, 111221, 312211, 13112221, 1113213211, 31131211131221, 13211311123113112211, 11131221133112132113212221, 3113112221232112111312211312113211, 1321132132111213122112311311222113111221131221, 11131221131211131231121113112221121321132132211331222113112211, 311311222113111231131112132112311321322112111312211312111322212311322113212221
Offset: 1

Views

Author

Keywords

Comments

Method A = "frequency" followed by "digit"-indication.
Also known as the "Say What You See" sequence.
Only the digits 1, 2 and 3 appear in any term. - Robert G. Wilson v, Jan 22 2004
All terms end with 1 (the seed) and, except the third a(3), begin with 1 or 3. - Jean-Christophe Hervé, May 07 2013
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
This sequence is called "suite de Conway" in French (see Wikipédia link). - Bernard Schott, Jan 10 2021
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

Examples

			The term after 1211 is obtained by saying "one 1, one 2, two 1's", which gives 111221.
		

References

  • John H. Conway and Richard K. Guy, The Book of Numbers, New York: Springer-Verlag, 1996. See p. 208.
  • S. R. Finch, Mathematical Constants, Cambridge, 2003, section 6.12 Conway's Constant, pp. 452-455.
  • M. Gilpin, On the generalized Gleichniszahlen-Reihe sequence, Manuscript, Jul 05 1994.
  • A. Lakhtakia and C. Pickover, Observations on the Gleichniszahlen-Reihe: An Unusual Number Theory Sequence, J. Recreational Math., 25 (No. 3, 1993), 192-198.
  • Clifford A. Pickover, Computers and the Imagination, St Martin's Press, NY, 1991.
  • 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.
  • C. A. Pickover, The Math Book, Sterling, NY, 2009; see p. 486.
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
  • James J. Tattersall, Elementary Number Theory in Nine Chapters, 1999, p. 23.
  • I. Vardi, Computational Recreations in Mathematica. Addison-Wesley, Redwood City, CA, 1991, p. 4.

Crossrefs

Cf. A001387, Periodic table: A119566.
Cf. A225224, A221646, A225212 (continuous versions).
Apart from the first term, all terms are in A001637.
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).
About primes: A079562 (number of distinct prime factors), A100108 (terms that are primes), A334132 (smallest prime factor).
Cf. A014715 (Conway's constant), A098097 (terms interpreted as written in base 4).

Programs

  • Haskell
    import List
    say :: Integer -> Integer
    say = read . concatMap saygroup . group . show
    where saygroup s = (show $ length s) ++ [head s]
    look_and_say :: [Integer]
    look_and_say = 1 : map say look_and_say
    -- Josh Triplett (josh(AT)freedesktop.org), Jan 03 2007
    
  • Haskell
    a005150 = foldl1 (\v d -> 10 * v + d) . map toInteger . a034002_row
    -- Reinhard Zumkeller, Aug 09 2012
    
  • Java
    See Paulo Ortolan link.
    
  • Mathematica
    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} ]
    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 *)
  • 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
  • Perl
    $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);
    # Jeff Quilici (jeff(AT)quilici.com), Aug 12 2003
    
  • Perl
    # This outputs the first n elements of the sequence, where n is given on the command line.
    $s = 1;
    for (2..shift @ARGV) {
    print "$s, ";
    $s =~ s/(.)\1*/(length $&).$1/eg;
    }
    # Arne 'Timwi' Heizmann (timwi(AT)gmx.net), Mar 12 2008
    print "$s\n";
    
  • Python
    def A005150(n):
        p = "1"
        seq = [1]
        while (n > 1):
            q = ''
            idx = 0 # Index
            l = len(p) # Length
            while idx < l:
                start = idx
                idx = idx + 1
                while idx < l and p[idx] == p[start]:
                    idx = idx + 1
                q = q + str(idx-start) + p[start]
            n, p = n - 1, q
            seq.append(int(p))
        return seq
    # Olivier Mengue (dolmen(AT)users.sourceforge.net), Jul 01 2005
    
  • Python
    def A005150(n):
        seq = [1] + [None] * (n - 1) # allocate entire array space
        def say(s):
            acc = '' # initialize accumulator
            while len(s) > 0:
                i = 0
                c = s[0] # char of first run
                while (i < len(s) and s[i] == c): # scan first digit run
                    i += 1
                acc += str(i) + c # append description of first run
                if i == len(s):
                    break # done
                else:
                    s = s[i:] # trim leading run of digits
            return acc
        for i in range(1, n):
            seq[i] = int(say(str(seq[i-1])))
        return seq
    # E. Johnson (ejohnso9(AT)earthlink.net), Mar 31 2008
    
  • Python
    # program without string operations
    def sign(n): return int(n > 0)
    def say(a):
        r = 0
        p = 0
        while a > 0:
            c = 3 - sign((a % 100) % 11) - sign((a % 1000) % 111)
            r += (10 * c + (a % 10)) * 10**(2*p)
            a //= 10**c
            p += 1
        return r
    a = 1
    for i in range(1, 26):
        print(i, a)
        a = say(a)
    # Volker Diels-Grabsch, Aug 18 2013
    
  • Python
    import re
    def lookandsay(limit, sequence = 1):
        if limit > 1:
            return lookandsay(limit-1, "".join([str(len(match.group()))+match.group()[0] for matchNum, match in enumerate(re.finditer(r"(\w)\1*", str(sequence)))]))
        else:
            return sequence
    # lookandsay(3) --> 21
    # Nicola Vanoni, Nov 29 2016
    
  • Python
    import itertools
    x = "1"
    for i in range(20):
        print(x)
        x = ''.join(str(len(list(g)))+k for k,g in itertools.groupby(x))
    # Matthew Cotton, Nov 12 2019
    

Formula

a(n+1) = A045918(a(n)). - Reinhard Zumkeller, Aug 09 2012
a(n) = Sum_{k=1..A005341(n)} A034002(n,k)*10^(A005341(n)-k). - Reinhard Zumkeller, Dec 15 2012
a(n) = A004086(A007651(n)). - Bernard Schott, Jan 08 2021
A055642(a(n+1)) = A005341(n+1) = 2*A043562(a(n)). - Ya-Ping Lu, Jan 28 2025
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
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

A005341 Length of n-th term in Look and Say sequences A005150 and A007651.

Original entry on oeis.org

1, 2, 2, 4, 6, 6, 8, 10, 14, 20, 26, 34, 46, 62, 78, 102, 134, 176, 226, 302, 408, 528, 678, 904, 1182, 1540, 2012, 2606, 3410, 4462, 5808, 7586, 9898, 12884, 16774, 21890, 28528, 37158, 48410, 63138, 82350, 107312, 139984, 182376, 237746, 310036, 403966, 526646, 686646
Offset: 1

Views

Author

Keywords

Comments

Row lengths of A034002 and of A220424. - Reinhard Zumkeller, Dec 15 2012
Satisfies a recurrence of order 72. The characteristic polynomial of this recurrence is a degree-72 polynomial that factors as (x-1)*q(x), where q(x) is a degree-71 polynomial. The unique positive real root of q is approximately 1.3036 and is called Conway's constant (A014715), which equals the limiting ratio a(n+1)/a(n). - Nathaniel Johnston, Apr 12 2018 [Corrected by Richard Stanley, Dec 26 2018]

References

  • J. H. Conway, The weird and wonderful chemistry of audioactive decay, in T. M. Cover and Gopinath, eds., Open Problems in Communication and Communications, Springer, NY 1987, pp. 173-188.
  • S. R. Finch, Mathematical Constants, Cambridge, 2003, pp. 452-455.
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Programs

  • Haskell
    a005341 = length . a034002_row  -- Reinhard Zumkeller, Dec 15 2012
  • Mathematica
    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[ Length[ F[ n ] ], {n, 1, 51} ]
    p = {12, -18, 18, -18, 18, -20, -22, 31, 15, -4, -4, -19, 62, -50, -21, -11, 41, 54, -56, -44, 15, -27, -15, 45, -8, 89, -64, -66, -25, 38, 126, -39, -32, -33, -65, 107, 14, 16, -13, -79, 7, 42, 12, 8, -26, -9, 35, -23, -20, -30, 34, 58, -1, -20, -36, -6, 13, 8, 6, 3, -1, -4, -1, -4, -5, -1, 8, 6, 0, -6, -4, 1, 0, 1, 1, 1, 1, -1, -1}; q = {-6, 9, -9, 18, -16, 11, -14, 8, -1, 5, -7, -2, -8, 14, 5, 5, -19, -3, 6, 7, 6, -16, 7, -8, 22, -17, 12, -7, -5, -7, 8, -4, 7, 9, -13, 4, 6, -14, 14, -19, 7, 13, -2, 4, -18, 0, 1, 4, 12, -8, 5, 0, -8, -1, -7, 8, 5, 2, -3, -3, 0, 0, 0, 0, 2, 1, 0, -3, -1, 1, 1, 1, -1}; gf = Fold[x #1 + #2 &, 0, p]/Fold[x #1 + #2 &, 0, q]; CoefficientList[Series[gf, {x, 0, 99}], x] (* Peter J. C. Moses, Jun 23 2013 *)
  • PARI
    print1(a=1);for(i=2,100,print1(",",#Str(a=A005150(2,a))))  \\ M. F. Hasler, Nov 08 2011
    

Formula

a(n) = A055642(A005150(n)) = A055642(A007651(n)). - Reinhard Zumkeller, Dec 15 2012

Extensions

More terms from Mike Keith

A004977 Sum of digits of n-th term in Look and Say sequence A005150.

Original entry on oeis.org

1, 2, 3, 5, 8, 10, 13, 16, 23, 32, 44, 56, 76, 102, 132, 174, 227, 296, 383, 505, 679, 892, 1151, 1516, 1988, 2602, 3400, 4410, 5759, 7519, 9809, 12810, 16710, 21758, 28356, 36955, 48189, 62805, 81803, 106647, 139088, 181301, 236453, 308150, 401689
Offset: 1

Views

Author

Keywords

Comments

It appears that the ratio of consecutive terms approaches Conway's constant 1.303.. (A014715). The terms divided by the numbers of added digits also would tend to a constant, i.e. A004977(n)/A005341(n)->const. If the digits in A005150 occur with constant probabilities c1, c2, c3 then A004977(n)=A005341(n)*(c1+2*c2+3*c3) and this conjecture entails the convergences noted here. - Alexandre Losev, Aug 31 2005

Crossrefs

Programs

  • Mathematica
    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[ Apply[ Plus, F[ n ] ], {n, 1, 51} ]
    p={-4,8,-7,-10,15,18,11,-65,-4,27,7,9,-62,47,56,-32,-46,-8,67,44,-16,24,2,-59,-20,-65,84,122,-51,-38,-131,10,91,24,39,-89,-42,39,12,45,-40,-63,39,40,10,-19,-58,47,51,-7,-43,-67,32,41,20,-13,-24,-3,8,0,0,0,0,10,5,-3,-11,-6,5,7,3,-2,-1,-1,-1,-1,0,1,1}; q={6,-9,9,-18,16,-11,14,-8,1,-5,7,2,8,-14,-5,-5,19,3,-6,-7,-6,16,-7,8,-22,17,-12,7,5,7,-8,4,-7,-9,13,-4,-6,14,-14,19,-7,-13,2,-4,18,0,-1,-4,-12,8,-5,0,8,1,7,-8,-5,-2,3,3,0,0,0,0,-2,-1,0,3,1,-1,-1,-1,1}; gf=Fold[x #1+#2&,0,p]/Fold[x #1+#2&,0,q]; CoefficientList[Series[gf,{x,0,99}],x] (* Peter J. C. Moses, Jun 24 2013 *)

A014967 Continued fraction for Conway's constant.

Original entry on oeis.org

1, 3, 3, 2, 2, 54, 5, 2, 1, 16, 1, 30, 1, 1, 1, 2, 2, 1, 14, 1, 6, 24, 107, 5, 1, 1, 26, 2, 41, 10, 1, 1, 5, 17, 5, 1, 8, 3, 94, 38, 1, 18, 1, 1, 2, 1, 64, 18, 1, 6, 1, 2, 2, 1, 23, 1, 4, 4, 1, 1, 3, 4, 1, 10, 1, 28, 4, 12, 1, 1238, 13, 1, 1, 58, 1, 2, 4, 1, 3, 7, 1, 3, 1, 4, 1, 1, 1, 1, 1, 1, 100
Offset: 0

Views

Author

Keywords

Examples

			1.303577269034296391257099112... = 1 + 1/(3 + 1/(3 + 1/(2 + 1/(2 + ...)))) [From _Harry J. Smith_, May 12 2009]
		

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, A014715, A014715 (decimal expansion).

Programs

  • Mathematica
    terms = 201; ContinuedFraction[x /. FindRoot[x^71 - x^69 - 2*x^68 - x^67 + 2*x^66 + 2*x^65 + x^64 - x^63 - x^62 - x^61 - x^60 - x^59 + 2*x^58 + 5*x^57 + 3*x^56 - 2*x^55 - 10*x^54 - 3*x^53 - 2*x^52 + 6*x^51 + 6*x^50 + x^49 + 9*x^48 - 3*x^47 - 7*x^46 - 8*x^45 - 8*x^44 + 10*x^43 + 6*x^42 + 8*x^41 - 5*x^40 - 12*x^39 + 7*x^38 - 7*x^37 + 7*x^36 + x^35 - 3*x^34 + 10*x^33 + x^32 - 6*x^31 - 2*x^30 - 10*x^29 - 3*x^28 + 2*x^27 + 9*x^26 - 3*x^25 + 14*x^24 - 8*x^23 - 7*x^21 + 9*x^20 + 3*x^19 - 4*x^18 - 10*x^17 - 7*x^16 + 12*x^15 + 7*x^14 + 2*x^13 - 12*x^12 - 4* x^11 - 2*x^10 + 5*x^9 + x^7 - 7*x^6 + 7*x^5 - 4*x^4 + 12*x^3 - 6*x^2 + 3*x - 6, {x, 1.3}, WorkingPrecision -> 1.3*terms], terms]
  • PARI
    { allocatemem(932245000); default(realprecision, 21000); x=NULL; r=solve(x=1, 2,\
    x^71-x^69-2*x^68-x^67+2*x^66+2*x^65+x^64-x^63-x^62-x^61-x^60\
    -x^59+2*x^58+5*x^57+3*x^56-2*x^55-10*x^54-3*x^53-2*x^52+6*x^51\
    +6*x^50+x^49+9*x^48-3*x^47-7*x^46-8*x^45-8*x^44+10*x^43+6*x^42\
    +8*x^41-5*x^40-12*x^39+7*x^38-7*x^37+7*x^36+x^35-3*x^34+10*x^33\
    +x^32-6*x^31-2*x^30-10*x^29-3*x^28+2*x^27+9*x^26-3*x^25+14*x^24\
    -8*x^23-7*x^21+9*x^20+3*x^19-4*x^18-10*x^17-7*x^16+12*x^15\
    +7*x^14+2*x^13-12*x^12-4*x^11-2*x^10+5*x^9+x^7-7*x^6+7*x^5\
    -4*x^4+12*x^3-6*x^2+3*x-6); c=contfrac(r); for (n=1, 20001, write("b014967.txt", n-1, " ", c[n])); } (End)

Extensions

More terms from Hans Havermann, Feb 15 2001
Deleted old PARI program Harry J. Smith, May 19 2009

A355316 Stuttering Look and Say sequence with seed 0.

Original entry on oeis.org

0, 10, 1110, 333110, 333322110, 4444322222110, 444441355555222110, 5555541113555555333222110, 5555551433311366666653333333222110, 6666665111433332211366666661577777773333222110, 66666661533311444443222221137777777611157777777744443333222110
Offset: 1

Views

Author

Jonathan Comes, Jun 28 2022

Keywords

Comments

If we let L(n) denote the number of digits in the n-th term, then the limit of L(n+1)/L(n) is an algebraic integer of degree 415. This limit is a stuttering analog of Conway's constant (see A014715).

Examples

			E.g., to obtain the term after 1110, we look at 1110 and see "three 1's and one 0". We then say what we saw by stuttering the counts as many times as the count prescribes: we stutter the "three" 3 times and the "one" 1 time (no stutter); so we say "three three three 1's and one 0" to get 333110.
		

Crossrefs

Stuttering variant of A001155.
Cf. A014715.

Programs

  • PARI
    first(n) = my(c, d=[0], x, res=vector(n)); for(i=2, n, c=1; x=""; for(j=1, #d, if(j<#d && d[j]==d[j+1], c++, x=concat(x, concat(vector(c+1, k, Str(if(k==c+1, d[j], c))))); c=1)); res[i]=eval(x); d=digits(res[i])); res \\ Iain Fox, Jun 30 2022
  • Python
    from itertools import accumulate, groupby, repeat
    def summarize(n, _): return int("".join(str(c:=len(list(g)))*c+k for k, g in groupby(str(n))))
    def aupton(terms): return list(accumulate(repeat(0, terms), summarize))
    print(aupton(11)) # Michael S. Branicky, Jun 28 2022
    

A137275 Coefficients of Conway's polynomial (powers of x in increasing order).

Original entry on oeis.org

-6, 3, -6, 12, -4, 7, -7, 1, 0, 5, -2, -4, -12, 2, 7, 12, -7, -10, -4, 3, 9, -7, 0, -8, 14, -3, 9, 2, -3, -10, -2, -6, 1, 10, -3, 1, 7, -7, 7, -12, -5, 8, 6, 10, -8, -8, -7, -3, 9, 1, 6, 6, -2, -3, -10, -2, 3, 5, 2, -1, -1, -1, -1, -1, 1, 2, 2, -1, -2, -1, 0, 1
Offset: 1

Views

Author

Zak Seidov, Mar 13 2008

Keywords

Examples

			-6+3x-6x^2+12x^3-4x^4+7x^5-7x^6+x^7+5x^9-2x^10-4x^11-
12x^12+2x^13+7x^14+12x^15-7x^16-10x^17-4x^18+3x^19+9x^20-7x^21-
8x^23+14x^24-3x^25+9x^26+2x^27-3x^28-10x^29-2x^30-6x^31+x^32+
10x^33-3x^34+x^35+7x^36-7x^37+7x^38-12x^39-5x^40+8x^41+6x^42+
10x^43-8x^44-8x^45-7x^46-3x^47+9x^48+x^49+6x^50+6x^51-2x^52-
3x^53-10x^54-2x^55+3x^56+5x^57+2x^58-x^59-x^60-x^61-x^62-x^63+
x^64+2x^65+2x^66-x^67-2x^68-x^69+x^71.
		

References

  • J. H. Conway, The weird and wonderful chemistry of audioactive decay, Eureka 46 (1986) 5-16.
  • 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

Showing 1-6 of 6 results.