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-10 of 297 results. Next

A054353 Partial sums of Kolakoski sequence A000002.

Original entry on oeis.org

1, 3, 5, 6, 7, 9, 10, 12, 14, 15, 17, 19, 20, 21, 23, 24, 25, 27, 29, 30, 32, 33, 34, 36, 37, 39, 41, 42, 43, 45, 46, 47, 49, 50, 52, 54, 55, 57, 59, 60, 61, 63, 64, 66, 68, 69, 71, 72, 73, 75, 76, 77, 79, 81, 82, 84, 86, 87, 88, 90, 91, 93, 95, 96, 98, 100
Offset: 1

Views

Author

N. J. A. Sloane, May 07 2000

Keywords

Comments

Alternate definition: n such that A000002(n) is different from A000002(n+1). - Nathaniel Johnston, May 02 2011

Crossrefs

Cf. A088568 (partial sums of [3 - 2*A000002(n)]).

Programs

  • Haskell
    a054353 n = a054353_list !! (n-1)
    a054353_list = scanl1 (+) a000002_list
    -- Reinhard Zumkeller, Aug 03 2013
    
  • Mathematica
    a2 = {1, 2, 2}; Do[ a2 = Join[a2, {1+Mod[n-1, 2]}], {n, 3, 50}, {a2[[n]] } ]; Accumulate[a2] (* Jean-François Alcover, Jun 18 2013 *)
  • Python
    from itertools import accumulate
    def alst(nn):
      K = Kolakoski() # using Kolakoski() in A000002
      return list(accumulate(next(K) for i in range(1, nn+1)))
    print(alst(66))   # Michael S. Branicky, Jan 12 2021

Formula

A000002(a(n)) = (3+(-1)^n)/2; A000002(a(n)+1)=(3-(-1)^n)/2. - Benoit Cloitre, Oct 16 2005
a(n) = n + A074286(n) = 2*n - A156077(n) = A156077(n) + 2*A074286(n). - Jean-Christophe Hervé, Oct 05 2014

A088568 3*n - 2*(partial sums of Kolakoski sequence A000002).

Original entry on oeis.org

1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, -2, -1, 0, -1, 0, 1, 0, -1, 0, -1, 0, 1, 0, 1, 0, -1, 0, 1, 0, 1, 2, 1, 2, 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, 1, 0, 1, 2, 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, -2, -1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, 1, 0, -1, 0, -1, -2, -1, 0, -1, 0, -1, -2, -1, -2, -3, -2, -1, -2, -1, 0, -1, -2, -1, -2, -1, 0, -1, 0, -1
Offset: 1

Views

Author

Benoit Cloitre, Nov 17 2003; definition changed Oct 16 2005

Keywords

Comments

It is conjectured that a(n) = o(n).
It is conjectured that the density of 1's and that of 2's in the Kolakoski sequence A000002 are equal to 1/2. The deficit of 2's in the Kolakoski sequence at rank n being defined as n/2 - number of 2's in the Kolakoski word of length n, a(n) is equal to twice the deficit of 2's (or twice the excess of 1's). Equivalently, the number of 2's up to rank n in the Kolakoski sequence is (n - a(n))/2. - Jean-Christophe Hervé, Oct 05 2014
The conjecture about the densities of 1's and 2's is equivalent to a(n) = o(n). The graph shows that a(n) seems to oscillate around 0 with a pseudo-periodic and fractal pattern. - Jean-Christophe Hervé, Oct 05 2014
It is conjectured that a(n) = O(log(n)) (see PlanetMath link). Note that for a random sequence of 1's and -1's, we would have O(sqrt(n)). - Daniel Forgues, Jul 10 2015
The linked PlanetMath text mentions 0.5*n + O(log(n)) only in respect of an empirical observation, apparently to support the density conjecture (the conjecture described above in the first comment dated Oct 05 2014). - Peter Munn, Aug 03 2022
The conjecture that a(n) = O(log(n)) seems incorrect as |a(n)| seems to grow as fast as sqrt(n), see A289323 and note that a(2^n) = -A289323(n), so for example a(2^64) = -A289323(64) = -836086974 which is much larger in absolute value than log(2^64), but about 0.19*2^32. - Richard P. Brent, Jul 07 2017
For n = 124 to 147, we have the same 24 values as for n = 42 to 65: {0, 1, 0, -1, 0, -1, 0, 1, 0, 1, 2, 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1}, and for n = 173 to 200, we have the same 28 values as for n = 11 to 38: {-1, -2, -1, 0, -1, 0, 1, 0, -1, 0, -1, 0, 1, 0, 1, 0, -1, 0, 1, 0, 1, 2, 1, 2, 1, 0, 1, 0}. - Daniel Forgues, Jul 11 2015

Examples

			The sequence A000002 starts 1, 2, 2, 1, 1, 2, ..., so the sixth partial sum is 1 + 2 + 2 + 1 + 1 + 2 = 9, and therefore a(6) = 3*6 - 2*9 = 0. - _Michael B. Porter_, Jul 08 2016
		

Crossrefs

Cf. A000002 (Kolakoski sequence), A054353 (partial sums of Kolakoski sequence), A156077 (number of 1's in the Kolakoski sequence).
For the discrepancy of the Kolakoski sequence see A294448 (this is simply the negation of the present sequence).
For records see A294449.

Formula

a(n) = 3*n - 2*A054353(n) by definition. - Jean-Christophe Hervé, Oct 05 2014
a(n) = 2*A156077(n) - n. - Jean-Christophe Hervé, Oct 05 2014

A078649 Numbers n such that A000002(n)=A000002(n+1) where A000002 is the Kolakoski sequence.

Original entry on oeis.org

2, 4, 8, 11, 13, 16, 18, 22, 26, 28, 31, 35, 38, 40, 44, 48, 51, 53, 56, 58, 62, 65, 67, 70, 74, 78, 80, 83, 85, 89, 92, 94, 97, 99, 103, 107, 110, 112, 115, 119, 121, 124, 126, 130, 133, 135, 138, 140, 144, 148, 150, 153, 157, 160, 162, 165, 167, 171, 175, 178, 180
Offset: 1

Views

Author

Benoit Cloitre, Dec 14 2002

Keywords

Comments

Complement sequence of A054353. - Benoit Cloitre, Feb 07 2009
This sequence is the union of A074262 and A074263. - Nathaniel Johnston, May 02 2011
A054354(a(n)-1) = 0. - Reinhard Zumkeller, Aug 03 2013
This is a subsequence of A216345. In particular, this consists of A216345(i) such that A000002(i) = A216345(i+1)-A216345(i) = 2. A013948 is the sequence of all such i. - Danny Rorabaugh, Mar 13 2015

Crossrefs

Programs

  • Haskell
    a078649 n = a078649_list !! (n-1)
    a078649_list = map (+ 1) $ filter ((== 0) . a054354) [1..]
    -- Reinhard Zumkeller, Aug 03 2013
  • Maple
    isA078649 := proc(n)
        if A000002(n) = A000002(n+1) then
            true;
        else
            false;
        end if;
    end proc:
    A078649 := proc(n)
        option remember;
        if n = 1 then
            2;
        else
            for a from procname(n-1)+1 do
                if isA078649(a) then
                    return a;
                end if;
            end do:
        end if;
    end proc:
    seq(A078649(n),n=1..50) ; # R. J. Mathar, Nov 15 2014
  • Mathematica
    a2 = {1, 2, 2}; Do[ a2 = Join[a2, {1+Mod[n-1, 2]}], {n, 3, 80}, {a2[[n]]}]; a3 = Accumulate[a2]; Complement[ Range[ Last[a3]], a3] (* Jean-François Alcover, Jun 18 2013 *)

Formula

a(n) is probably asymptotic to 3*n.
a(n) = A216345(A013948(n)). - Danny Rorabaugh, Mar 13 2015

A054354 First differences of Kolakoski sequence A000002.

Original entry on oeis.org

1, 0, -1, 0, 1, -1, 1, 0, -1, 1, 0, -1, 0, 1, -1, 0, 1, 0, -1, 1, -1, 0, 1, -1, 1, 0, -1, 0, 1, -1, 0, 1, -1, 1, 0, -1, 1, 0, -1, 0, 1, -1, 1, 0, -1, 1, -1, 0, 1, -1, 0, 1, 0, -1, 1, 0, -1, 0, 1, -1, 1, 0, -1, 1, 0, -1, 0, 1, -1, 0, 1, -1, 1, 0, -1, 1, -1, 0, 1, 0, -1, 1, 0, -1, 0, 1, -1, 1, 0, -1, 1, 0, -1
Offset: 1

Views

Author

N. J. A. Sloane, May 07 2000

Keywords

Comments

The Kolakoski sequence has only 1's and 2's, and is cubefree. Thus, for all n>=1, a(n) is in {-1, 0, 1}, a(n+1) != a(n), and if a(n) = 0, a(n+1) = -a(n-1), while if a(n) != 0, either a(n+1) = 0 and a(n+2) = -a(n) or a(n+1) = -a(n). A further consequence is that the maximum gap between equal values is 4: for all n, there is an integer k, 1Jean-Christophe Hervé, Oct 05 2014
From Daniel Forgues, Jul 07 2015: (Start)
Second differences: {-1, -1, 1, 1, -2, 2, -1, -1, 2, -1, -1, 1, 1, ...}
The sequence of first differences bounces between -1 and 1 with a slope whose absolute value is either 1 or 2. We can compress the information in the second differences into {-1, 1, -2, 2, -1, 2, -1, 1, ...} since the -1 and the 1 come in pairs; which can be compressed further into {1, 1, 2, 2, 1, 2, 1, 1, ...} since the signs alternate, where we only need to know that the initial sign is negative. (End)
This appears to divide the positive integers into three sets, each with density approaching 1/3. Note there are no adjacent equal parts (as mentioned above). - Gus Wiseman, Oct 10 2024

Crossrefs

Positions of 0 are A078649.
For Golomb's sequence (A001462) we have A088517.
Positions of -1 are A156242 (descents).
Positions of 1 are A156243 (ascents).
First differences (or second differences of A000002) are A376604.
The Kolakoski sequence (A000002):
- Statistics: A074286, A088568, A156077, A156253.
- Transformations: A054354, A156728, A306323, A332273, A332875, A333229.
Cf. A333254.

Programs

  • Haskell
    a054354 n = a054354_list !! (n-1)
    a054354_list = zipWith (-) (tail a000002_list) a000002_list
    -- Reinhard Zumkeller, Aug 03 2013
  • Mathematica
    a2 = {1, 2, 2}; Do[ a2 = Join[a2, {1 + Mod[n - 1, 2]}], {n, 3, 70}, {a2[[n]]}]; Differences[a2] (* Jean-François Alcover, Jun 18 2013 *)

Formula

Abs(a(n)) = (A000002(n)+A000002(n+1)) mod 2. - Benoit Cloitre, Nov 17 2003

A296658 Length of the standard Lyndon word factorization of the first n terms of A000002.

Original entry on oeis.org

1, 1, 1, 2, 3, 2, 3, 2, 2, 3, 2, 2, 3, 4, 3, 4, 5, 4, 3, 4, 3, 4, 5, 4, 5, 3, 3, 4, 5, 4, 5, 6, 5, 6, 4, 4, 5, 4, 4, 5, 6, 5, 6, 4, 4, 5, 4, 5, 6, 5, 6, 7, 6, 4, 5, 4, 4, 5, 6, 5, 6, 4, 4, 5, 4, 4, 5, 6, 5, 6, 7, 6, 7, 5, 5, 6, 5, 6, 7, 6, 5, 6, 5, 5, 6, 7, 6
Offset: 1

Views

Author

Gus Wiseman, Dec 18 2017

Keywords

Examples

			The standard Lyndon word factorization of (12211212212211211) is (122)(112122122)(112)(1)(1), so a(17) = 5.
The standard factorizations of initial terms of A000002:
1
12
122
122,1
122,1,1
122,112
122,112,1
122,11212
122,112122
122,112122,1
122,11212212
122,112122122
122,112122122,1
122,112122122,1,1
122,112122122,112
122,112122122,112,1
122,112122122,112,1,1
122,112122122,112,112
122,112122122,1121122
122,112122122,1121122,1
		

Crossrefs

Programs

  • Mathematica
    LyndonQ[q_]:=Array[OrderedQ[{q,RotateRight[q,#]}]&,Length[q]-1,1,And]&&Array[RotateRight[q,#]&,Length[q],1,UnsameQ];
    qit[q_]:=If[#===Length[q],{q},Prepend[qit[Drop[q,#]],Take[q,#]]]&[Max@@Select[Range[Length[q]],LyndonQ[Take[q,#]]&]];
    kolagrow[q_]:=If[Length[q]<2,Take[{1,2},Length[q]+1],Append[q,Switch[{q[[Length[Split[q]]]],Part[q,-2],Last[q]},{1,1,1},0,{1,1,2},1,{1,2,1},2,{1,2,2},0,{2,1,1},2,{2,1,2},2,{2,2,1},1,{2,2,2},1]]];
    Table[Length[qit[Nest[kolagrow,1,n]]],{n,150}]

A329315 Irregular triangle read by rows where row n gives the sequence of lengths of components of the Lyndon factorization of the first n terms of A000002.

Original entry on oeis.org

1, 2, 3, 3, 1, 3, 1, 1, 3, 3, 3, 3, 1, 3, 5, 3, 6, 3, 6, 1, 3, 8, 3, 9, 3, 9, 1, 3, 9, 1, 1, 3, 9, 3, 3, 9, 3, 1, 3, 9, 3, 1, 1, 3, 9, 3, 3, 3, 9, 7, 3, 9, 7, 1, 3, 9, 9, 3, 9, 9, 1, 3, 9, 9, 1, 1, 3, 9, 9, 3, 3, 9, 9, 3, 1, 3, 9, 14, 3, 9, 15, 3, 9, 15, 1, 3
Offset: 1

Views

Author

Gus Wiseman, Nov 11 2019

Keywords

Comments

There are no repeated rows, as row n has sum n.
We define the Lyndon product of two or more finite sequences to be the lexicographically maximal sequence obtainable by shuffling the sequences together. For example, the Lyndon product of (231) with (213) is (232131), the product of (221) with (213) is (222131), and the product of (122) with (2121) is (2122121). A Lyndon word is a finite sequence that is prime with respect to the Lyndon product. Equivalently, a Lyndon word is a finite sequence that is lexicographically strictly less than all of its cyclic rotations. Every finite sequence has a unique (orderless) factorization into Lyndon words, and if these factors are arranged in lexicographically decreasing order, their concatenation is equal to their Lyndon product. For example, (1001) has sorted Lyndon factorization (001)(1).
It appears that some numbers (such as 4) never appear in the sequence.

Examples

			Triangle begins:
   1: (1)
   2: (2)
   3: (3)
   4: (3,1)
   5: (3,1,1)
   6: (3,3)
   7: (3,3,1)
   8: (3,5)
   9: (3,6)
  10: (3,6,1)
  11: (3,8)
  12: (3,9)
  13: (3,9,1)
  14: (3,9,1,1)
  15: (3,9,3)
  16: (3,9,3,1)
  17: (3,9,3,1,1)
  18: (3,9,3,3)
  19: (3,9,7)
  20: (3,9,7,1)
For example, the first 10 terms of A000002 are (1221121221), with Lyndon factorization (122)(112122)(1), so row 10 is (3,6,1).
		

Crossrefs

Row lengths are A296658.
The reversed version is A329316.

Programs

  • Mathematica
    lynQ[q_]:=Array[Union[{q,RotateRight[q,#1]}]=={q,RotateRight[q,#1]}&,Length[q]-1,1,And];
    lynfac[q_]:=If[Length[q]==0,{},Function[i,Prepend[lynfac[Drop[q,i]],Take[q,i]]][Last[Select[Range[Length[q]],lynQ[Take[q,#1]]&]]]];
    kolagrow[q_]:=If[Length[q]<2,Take[{1,2},Length[q]+1],Append[q,Switch[{q[[Length[Split[q]]]],q[[-2]],Last[q]},{1,1,1},0,{1,1,2},1,{1,2,1},2,{1,2,2},0,{2,1,1},2,{2,1,2},2,{2,2,1},1,{2,2,2},1]]];
    kol[n_Integer]:=Nest[kolagrow,{1},n-1];
    Table[Length/@lynfac[kol[n]],{n,100}]

A288605 Position of first appearance of each integer in A088568 (number of 1's minus number of 2's in first n terms of A000002).

Original entry on oeis.org

0, 1, 3, 12, 32, 93, 257, 378, 471, 798, 825, 858, 1127, 1398, 1497, 1524, 1533, 6352, 6969, 7176, 7269, 7566, 7971, 20338, 20371, 21982, 22009, 25638, 25665, 25692, 27969, 39184, 39211, 42398, 43129, 43150, 48637, 48730, 48757, 49014, 49041, 49068, 49095, 49864
Offset: 1

Views

Author

Gus Wiseman, Jun 11 2017

Keywords

Comments

For the definition of this sequence we assume A088568(0) = 0.

Examples

			A088568(12) = -2 is the first appearance of -2 in A088568, so 12 belongs to the sequence.
A088568(32) = 2 is the first appearance of 2, so 32 belongs to the sequence.
		

Crossrefs

Programs

  • Mathematica
    Map[First, Values@ #] - 1 &@ PositionIndex@ Prepend[#, 0] &@ MapIndexed[3 First@ #2 - 2 #1 &, Accumulate@ Prepend[Nest[Flatten[Partition[#, 2] /. {{2, 2} -> {2, 2, 1, 1}, {2, 1} -> {2, 2, 1}, {1, 2} -> {2, 1, 1}, {1, 1} -> {2, 1}}] &, {2, 2}, 25], 1]] (* Michael De Vlieger, Jun 12 2017, after Birkas Gyorgy at A000002 *)

A376604 Second differences of the Kolakoski sequence (A000002). First differences of A054354.

Original entry on oeis.org

-1, -1, 1, 1, -2, 2, -1, -1, 2, -1, -1, 1, 1, -2, 1, 1, -1, -1, 2, -2, 1, 1, -2, 2, -1, -1, 1, 1, -2, 1, 1, -2, 2, -1, -1, 2, -1, -1, 1, 1, -2, 2, -1, -1, 2, -2, 1, 1, -2, 1, 1, -1, -1, 2, -1, -1, 1, 1, -2, 2, -1, -1, 2, -1, -1, 1, 1, -2, 1, 1, -2, 2, -1, -1
Offset: 1

Views

Author

Gus Wiseman, Oct 02 2024

Keywords

Comments

Since A000002 has no runs of length 3, this sequence contains no zeros.
The densities appear to approach (1/3, 1/3, 1/6, 1/6).

Examples

			The Kolakoski sequence (A000002) is:
  1, 2, 2, 1, 1, 2, 1, 2, 2, 1, 2, 2, 1, 1, 2, 1, 1, 2, 2, 1, 2, 1, 1, 2, 1, 2, 2, ...
with first differences (A054354):
  1, 0, -1, 0, 1, -1, 1, 0, -1, 1, 0, -1, 0, 1, -1, 0, 1, 0, -1, 1, -1, 0, 1, -1, ...
with first differences (A376604):
  -1, -1, 1, 1, -2, 2, -1, -1, 2, -1, -1, 1, 1, -2, 1, 1, -1, -1, 2, -2, 1, 1, -2, ...
		

Crossrefs

A001462 is Golomb's sequence.
A078649 appears to be zeros of the first and third differences.
A288605 gives positions of first appearances of each balance.
A306323 gives a 'broken' version.
A333254 lists run-lengths of differences between consecutive primes.
For the Kolakoski sequence (A000002):
- Restrictions: A074264, A100428, A100429, A156263, A156264.
- Transformations: A054354, A156728, A332273, A332875, A333229, A376604.
For second differences: A036263 (prime), A073445 (composite), A376559 (perfect-power), A376562 (non-perfect-power), A376590 (squarefree), A376593 (nonsquarefree), A376596 (prime-power), A376599 (non-prime-power).

Programs

  • Mathematica
    kolagrow[q_]:=If[Length[q]<2,Take[{1,2},Length[q]+1],Append[q,Switch[{q[[Length[Split[q]]]],q[[-2]],Last[q]},{1,1,2},1,{1,2,1},2,{2,1,1},2,{2,1,2},2,{2,2,1},1,{2,2,2},1]]]
    kol[n_]:=Nest[kolagrow,{1},n-1];
    Differences[kol[100],2]

A042942 From substitutional generation of Kolakoski sequence (A000002).

Original entry on oeis.org

1, 2, 4, 6, 9, 14, 22, 33, 49, 74, 112, 169, 254, 381, 573, 862, 1292, 1936, 2902, 4352, 6525, 9788, 14687, 22028, 33050, 49576, 74378, 111579, 167387, 251089, 376630, 564931, 847375, 1271058, 1906627, 2859983, 4289952, 6434942, 9652396
Offset: 1

Views

Author

Keywords

Comments

Generate A000002 via 2 -> 22 -> 2211 -> 221121 -> 221121221 -> ...; sequence gives lengths of successive strings.
a(n) appears to be asymptotic to c*(3/2)^n where c=1.3094... - Benoit Cloitre, Dec 18 2002
A more accurate estimate is c=1.309346948, probably correct to one unit in the last place. - Richard P. Brent, Dec 30 2016

Crossrefs

Formula

a(n) = A001083(n-2) - 1. - Andrey Zabolotskiy, Jan 10 2022

A156077 a(n) = #{1<=k<=n : A000002(k)=1}.

Original entry on oeis.org

1, 1, 1, 2, 3, 3, 4, 4, 4, 5, 5, 5, 6, 7, 7, 8, 9, 9, 9, 10, 10, 11, 12, 12, 13, 13, 13, 14, 15, 15, 16, 17, 17, 18, 18, 18, 19, 19, 19, 20, 21, 21, 22, 22, 22, 23, 23, 24, 25, 25, 26, 27, 27, 27, 28, 28, 28, 29, 30, 30, 31, 31, 31, 32, 32, 32, 33, 34, 34, 35, 36, 36, 37, 37, 37, 38
Offset: 1

Views

Author

Benoit Cloitre, Feb 03 2009

Keywords

Comments

A234322(n) = nearest integer to 100*a(n)/n. [Jonathan Sondow, Jan 08 2014]

Crossrefs

Programs

  • Mathematica
    a2 = {1, 2, 2}; Do[ a2 = Join[a2, {1 + Mod[n - 1, 2]}], {n, 3, 60}, {i, 1, a2[[n]]}]; a3 = Accumulate[a2]; 2*Range[Length[a3]] - a3 (* Jean-François Alcover, Jun 18 2013 *)

Formula

a(n) = n-A074286(n).
a(n) = 2*n - A054353(n). - Jean-Christophe Hervé, Oct 05 2014
Showing 1-10 of 297 results. Next