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.

Previous Showing 31-40 of 297 results. Next

A074263 Positions of '22' in Kolakoski sequence A000002.

Original entry on oeis.org

2, 8, 11, 18, 26, 35, 38, 44, 53, 56, 62, 65, 74, 80, 83, 89, 92, 99, 107, 110, 119, 126, 135, 138, 144, 150, 153, 162, 165, 171, 180, 188, 197, 203, 206, 212, 215, 224, 231, 234, 242, 249, 258, 261, 269, 278, 281, 287, 296, 299, 305, 308, 314, 317, 324, 332
Offset: 1

Views

Author

Jon Perry, Sep 20 2002

Keywords

Examples

			Kolakoski sequence begins 1,2,2,1,1,2,1,2,2,1,2,2,1,1,... so the sequence includes 2, 8, and 11.
		

Crossrefs

Cf. A074262.

Programs

  • Mathematica
    a2 = {1, 2, 2}; Do[ a2 = Join[a2, {1 + Mod[n - 1, 2]}], {n, 3, 300}, {i, 1, a2[[n]]}]; Split[a2] /. {2, 2} -> {0, 2} // Flatten // Position[#, 0] & // Flatten (* Jean-François Alcover, Jun 18 2013 *)

Extensions

Extended and offset changed by Nathaniel Johnston, May 02 2011

A216345 Position of the beginning of the n-th run in A000002.

Original entry on oeis.org

1, 2, 4, 6, 7, 8, 10, 11, 13, 15, 16, 18, 20, 21, 22, 24, 25, 26, 28, 30, 31, 33, 34, 35, 37, 38, 40, 42, 43, 44, 46, 47, 48, 50, 51, 53, 55, 56, 58, 60, 61, 62, 64, 65, 67, 69, 70, 72, 73, 74, 76, 77, 78, 80, 82, 83, 85, 87, 88, 89, 91, 92, 94, 96, 97, 99, 101, 102, 103
Offset: 1

Views

Author

Jon Perry, Sep 04 2012

Keywords

Comments

If n is odd then the run is 1's, otherwise it's 2's.

Examples

			Kolakoski sequence starts 1221121 so we can see that this sequence begins 1,2,4,6,7.
		

Crossrefs

Programs

  • Haskell
    a216345 n = a216345_list !! (n-1)
    a216345_list = 1 : (filter (\x -> a000002 x /= a000002 (x - 1)) [2..])
    -- Reinhard Zumkeller, Aug 03 2013
  • JavaScript
    a=new Array();
    a[1]=1;  a[2]=2;  a[3]=2;
    cd=1;  ap=3;
    for (i=4; i<50; i++)
    {
        if (a[ap]==1) a[i]=cd;
        else {a[i]=cd; a[i+1]=cd; i++}
        ap++;
        cd=3-cd;
    }
    /* document.write(a); document.write("
    "); */ b=new Array(); b[1]=1; c=2; for (i=2; i<50; i++) if (a[i]!=a[i-1]) b[c++]=i; document.write(b);

Formula

{n: A156728(n-1)=1}. - R. J. Mathar, Sep 14 2012
a(n+1) = A054353(n)+1 = a(n) + A000002(n). - Jean-Christophe Hervé, Oct 05 2014

A246144 Limiting block extension of A000002 (Kolakoski sequence) with first term as initial block.

Original entry on oeis.org

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

Views

Author

Keywords

Comments

Suppose S = (s(0), s(1), s(2), ...) is an infinite sequence such that every finite block of consecutive terms occurs infinitely many times in S. (It is assumed that A000002 is such a sequence.) Let B = B(m,k) = (s(m), s(m+1),...s(m+k)) be such a block, where m >= 0 and k >= 0. Let m(1) be the least i > m such that (s(i), s(i+1),...,s(i+k)) = B(m,k), and put B(m(1),k+1) = (s(m(1)), s(m(1)+1),...s(m(1)+k+1)). Let m(2) be the least i > m(1) such that (s(i), s(i+1),...,s(i+k)) = B(m(1),k+1), and put B(m(2),k+2) = (s(m(2)), s(m(2)+1),...s(m(2)+k+2)). Continuing in this manner gives a sequence of blocks B'(n) = B(m(n),k+n), so that for n >= 0, B'(n+1) comes from B'(n) by suffixing a single term; thus the limit of B'(n) is defined; we call it the "limiting block extension of S with initial block B(m,k)", denoted by S^ in case the initial block is s(0).
The sequence (m(i)), where m(0) = 0, is the "index sequence for limit-block extending S with initial block B(m,k)", as in A246128. If the sequence S is given with offset 1, then the role played by s(0) in the above definitions is played by s(1) instead, as in the case of A246144 and A246145.
Limiting block extensions are analogous to limit-reverse sequences, S*, defined at A245920. The essential difference is that S^ is formed by extending each new block one term to the right, whereas S* is formed by extending each new block one term to the left (and then reversing).

Examples

			S = A000002, with B = (s(1)); that is, (m,k) = (1,0)
S = (1,2,2,1,1,2,1,2,2,1,2,2,1,1,2,1,1,2,2,1,2,1,...)
B'(0) = (1)
B'(1) = (1,1)
B'(2) = (1,1,2)
B'(3) = (1,1,2,2)
B'(4) = (1,1,2,2,1)
B'(5) = (1,1,2,2,1,2)
S^ = (1,1,2,2,1,2,1,1,2,1,2,2,1,1,2,1,1,...),
with index sequence (1,4,13,16,51,78,97,124,178,247,322,...)
		

Crossrefs

Programs

  • Mathematica
    seqPosition1[list_, seqtofind_] := If[Length[#] > Length[list], {}, Last[Last[Position[Partition[list, Length[#], 1], Flatten[{_, #, _}], 1, 1]]]] &[seqtofind]; n = 30; s = 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}, n], 1]; (* A246144 *)
    Take[s, 30]
    t = {{1}}; p[0] = seqPosition1[s, Last[t]]; s = Drop[s, p[0]]; Off[Last::nolast]; n = 1; While[(p[n] = seqPosition1[s, Last[t]]) > 0, (AppendTo[t, Take[s, {#, # + Length[Last[t]]}]]; s = Drop[s, #]) &[p[n]]; n++]; On[Last::nolast]; Last[t] (* A246144*)
    Accumulate[Table[p[k], {k, 0, n - 1}]] (*A246145*)

A249093 Length of self-iteration of the Kolakoski sequence A000002 starting at A000002(n): a(n) = max { k | A000002(n+i-1) = A000002(i), 0 < i <= k }.

Original entry on oeis.org

0, 0, 1, 2, 0, 4, 0, 0, 7, 0, 0, 1, 2, 0, 1, 4, 0, 0, 2, 0, 1, 2, 0, 7, 0, 0, 1, 2, 0, 1, 2, 0, 4, 0, 0, 11, 0, 0, 1, 2, 0, 4, 0, 0, 2, 0, 1, 2, 0, 1, 4, 0, 0, 18, 0, 0, 1, 2, 0, 4, 0, 0, 7, 0, 0, 1, 2, 0, 1, 2, 0, 4, 0, 0, 2, 0, 1, 4, 0, 0, 28, 0, 0, 1, 2, 0, 4
Offset: 2

Views

Author

Jean-Christophe Hervé, Oct 28 2014

Keywords

Comments

The Kolakoski sequence A000002 has a fractal structure that appears in the infinite number of iterations of itself that it contains. This sequence gives the length of the iteration starting at position n (with a length = 0 if A000002(n) = 2 <> A000002(1) = 1).
Recalling that A000002 begins as 1221121221..., the apparition of these iterations is easily understood from the evolution of an initial 2 in even position in A000002, which generates: 2 > (1)22(1) > (2)122112(1) > (1)221221121221(2)... (as long as the equivalent of the initial 2 in the successive iterates remains in even position). This example shows that the iterations are growing forward and backward in a symmetric pattern. The lengths of the backward iterations are in A249094 and the lengths of the full iterations with the two branches are in A249507.
Because each iteration must be generated by a preceding (and shorter) iteration, each branch is constituted of a term of A054351 (successive generations of the Kolakoski sequence), and the nonzero values of this sequence are all in A054352. That is, the only possible nonzero lengths of iterations are 1, 2, 4, 7, 11, ..., and a given value > 1 cannot appear in this sequence before the other smaller values.
Conjecture: for any k, there is an iteration of length A054352(k) in A000002.

Examples

			A000002(n) = 2 => a(n) = 0 since the Kolakoski sequence begins with 1. a(7) = 4 since A000002(7:10) = A000002(1:4) and A000002(11) <> A000002(5).
		

Crossrefs

A249094 Length of reverse self-iteration of the Kolakoski sequence A000002 starting at A000002(n): a(n) = max { k | A000002(n-i+1) = A000002(i), 0 < i <= k }.

Original entry on oeis.org

0, 0, 4, 1, 0, 2, 0, 0, 4, 0, 0, 4, 1, 0, 2, 1, 0, 0, 7, 0, 2, 1, 0, 2, 0, 0, 4, 1, 0, 2, 1, 0, 2, 0, 0, 4, 0, 0, 4, 1, 0, 2, 0, 0, 4, 0, 2, 1, 0, 2, 1, 0, 0, 7, 0, 0, 4, 1, 0, 2, 0, 0, 4, 0, 0, 4, 1, 0, 2, 1, 0, 2, 0, 0, 4, 0, 2, 1, 0, 0, 11, 0, 0, 4, 1, 0, 2
Offset: 2

Views

Author

Jean-Christophe Hervé, Oct 30 2014

Keywords

Comments

The Kolakoski sequence A000002 has a fractal structure that appears in the infinite number of iterations and reverse iterations of itself that it contains. Each iteration develops itself in two branches, a right branch in the direct sense, and a left branch in the reverse sense, e.g., 122-1-221121. This sequence gives the length of the reverse iteration (or left branch) starting at position n, with a length = 0 if A000002(n) = 2 <> A000002(1) = 1.
The lengths of the right branches are in A249093 and the lengths of the full iterations with the two branches are in A249507.
Recalling that A000002 begins as 1221121221..., the apparition of these iterations is easily understood from the evolution of an initial 2 in even position in A000002, which generates: 2 > (1)22(1) > (2)122112(1) > (1)221221121221(2)... (as long as the equivalent of the initial 2 in the successive iterates remains in even position).
Because each iteration must be generated by a preceding (and shorter) iteration, each branch is constituted of a term of A054351 (successive generations of the Kolakoski sequence) in reverse order for the left branches, and the nonzero values of this sequence are all in A054352. Any given value > 1 cannot appear in this sequence before the other smaller values.

Examples

			A000002(n) = 2 => a(n) = 0 since the Kolakoski sequence begins with 1. a(10) = 4 since A000002(7:10) = A000002(1:4) and A000002(6) <> A000002(5).
		

Crossrefs

A379046 Rectangular array read by descending antidiagonals: the Type 1 runlength index array of A000002 (the Kolakoski sequence); see Comments.

Original entry on oeis.org

1, 2, 3, 4, 5, 12, 6, 9, 17, 32, 7, 14, 39, 66, 93, 8, 19, 52, 125, 134, 257, 10, 23, 57, 154, 318, 351, 378, 11, 27, 71, 194, 512, 639, 702, 471, 13, 29, 84, 216, 553, 1627, 1672, 789, 798, 15, 36, 98, 230, 594, 2141, 2168, 1747, 1960, 825, 16, 41, 111, 309
Offset: 1

Views

Author

Clark Kimberling, Dec 16 2024

Keywords

Comments

We begin with a definition of Type 1 runlength array, U(s), of a sequence s:
Suppose s is a sequence (finite or infinite), and define rows of U(s) as follows:
(row 0) = s
(row 1) = sequence of 1st terms of runs in (row 0); c(1) = complement of (row 1) in (row 0)
For n>=2,
(row n) = sequence of 1st terms of runs in c(n-1); c(n) = complement of (row n) in (row n-1),
where the process stops if and when c(n) is empty for some n.
***
The corresponding Type 1 runlength index array, UI(s) is now contructed from U(s) in two steps:
(1) Let U*(s) be the array obtaining by repeating the construction of U(s) using (n,s(n)) in place of s(n).
(2) Then UI(s) results by retaining only n in U*.
Thus, loosely speaking, (row n) of UI(s) shows the indices in s of the numbers in (row n) of U(s).
The array UI(s) includes every positive integer exactly once.

Examples

			Corner:
     1     2     4     6     7     8    10    11     13     15     16     18
     3     5     9    14    19    23    27    29     36     41     45     49
    12    17    39    52    57    71    84    98    111    116    139    161
    32    66   125   154   194   216   230   309    430    462    491    526
    93   134   318   512   553   594   943  1004   1330   1371   1594   1826
   257   351   639  1627  2141  2490  2612  2869   3501   3761   3990   4191
   378   702  1672  2168  2896  3564  3806  4017   4218   4935   5054   5418
   471   789  1747  2729  2905  3651  4547  6578   6763   7768   7962   8185
   798  1960  2756  2932  3660  4574  6659  6936   8368   9370  10296  12393
   825  1987  2783  3415  3687  4601  8455  9433  10359  12426  13180  15836
Starting with s = A000002, we have for U*(s):
(row 1) = ((1,1), (2,2), (4,1), (6,2), (7,1), (8,2), (10,1), (11,2), (13,1), ...)
c(1) = ((3,2), (5,1), (9,2), (12,2), (14,1), (17,1), (19,2), (23,1), (27,2), ...)
(row 2) = ((3,2), (5,1), (9,2), (14,1), (19,2), (23,1), (27,2), (29,1), (36,2), ...)
c(2) = ((12,2), (17,1), (32,1), (39,2), (52,1), (57,2), (66,2), (71,1), ...)
(row 3) = ((12,2), (17,1), (39,2), (52,1), (57,2), (71,1), ...)
so that UI(s) has
(row 1) = (1,2,4,6,7,8,10,11,13,...)
(row 2) = (3,5,9,14,19,...)
(row 3) = (12,17,32,66,...)
		

Crossrefs

Cf. A000002, A379047 (Type 2 array).

Programs

  • Mathematica
    r[seq_] := seq[[Flatten[Position[Prepend[Differences[seq[[All, 1]]], 1], _?(# != 0 &)]], 2]];  (* Type 1 *)
    row[0] = 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}, 24], 1]; (* A000002 *)
    row[0] = Transpose[{#, Range[Length[#]]}] &[row[0]];
    k = 0; Quiet[While[Head[row[k]] === List, row[k + 1] = row[0][[r[
         SortBy[Apply[Complement, Map[row[#] &, Range[0, k]]], #[[2]] &]]]]; k++]];
    m = Map[Map[#[[2]] &, row[#]] &, Range[k - 1]];
    p[n_] := Take[m[[n]], 12]
    t = Table[p[n], {n, 1, 12}]
    Grid[t]  (* array *)
    w[n_, k_] := t[[n]][[k]];
    Table[w[n - k + 1, k], {n, 12}, {k, n, 1, -1}] // Flatten  (* sequence *)
    (* Peter J. C. Moses, Dec 04 2024 *)

A001083 Length of one version of Kolakoski sequence {A000002(i)} at n-th growth stage.

Original entry on oeis.org

1, 2, 2, 3, 5, 7, 10, 15, 23, 34, 50, 75, 113, 170, 255, 382, 574, 863, 1293, 1937, 2903, 4353, 6526, 9789, 14688, 22029, 33051, 49577, 74379, 111580, 167388, 251090, 376631, 564932, 847376, 1271059, 1906628, 2859984
Offset: 1

Views

Author

Keywords

Examples

			/* generate sequence of sequences by recursion using next1() ( origin 1 ) */
v=[2]; for(n=1,8,p1(v); print1(" -> "); v=next1(v))
2 -> 11 -> 12 -> 122 -> 12211 -> 1221121 -> 1221121221 -> 122112122122112 ->
v=[2]; for(n=1,8,print1(length(v)); print1(","); v=next1(v)) gives: 1,2,2,3,5,7,10,15,
		

Crossrefs

Programs

  • PARI
    /* generate sequence starting at 1 given run length sequence */
    next1(v)=local(w); w=[]; for(n=1,length(v), for(i=1,v[n],w=concat(w,2-n%2))); w
    /* print a number or sequence recursively with no commas */
    p1(v)=if(type(v)!="t_VEC",print1(v), for(n=1,length(v),p1(v[n])))

Formula

Conjecture: a(n) is asymptotic to c*(3/2)^n where c=0.5819.... - Benoit Cloitre, Jun 01 2004
For n >= 1, a(n+3) = S^n(2) where S(n) = A054353(n) and S^k(2) = S(S^(k-1)(2)). - Benoit Cloitre, Feb 24 2009 [adjusted to match sequence offset by Jon Maiga, Jul 27 2022]
Equivalently, a(n) = A054353(a(n-1)) for n>3. - Jon Maiga, Jul 10 2022

Extensions

Corrected by and better description from Michael Somos, May 05 2000

A022294 a(n) is the least k>1 such that first n terms of Kolakoski sequence A000002 repeat beginning at k-th term.

Original entry on oeis.org

4, 5, 7, 7, 10, 10, 10, 37, 37, 37, 37, 55, 55, 55, 55, 55, 55, 55, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 460, 460, 460, 460, 460, 460, 460, 460, 460, 460, 460, 460, 460, 460, 460, 15585, 15585, 15585, 15585, 15585, 15585, 15585, 15585, 15585, 15585, 15585, 15585
Offset: 1

Views

Author

Keywords

Examples

			a(3) and a(4) are both 7 because A000002 begins 1, 2, 2, 1, 1, 2, 1, 2, 2, 1, 2, ... and 1, 2, 2 and 1, 2, 2, 1 both repeat at position 7.
		

Crossrefs

Programs

  • C
    See Links section.
  • Mathematica
    n = 22; seq = 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}, n], 1]; (* A000002 *)
    seq = StringJoin[Map[ToString, seq]]; Most[Flatten[Rest[Reap[NestWhile[# + 1 &, 1,
    Sow[First[Last[StringPosition[seq,
    StringTake[seq, #], 2]]]] > 1 &]]]]]  (* Peter J. C. Moses, Jan 05 2017 *)

A049705 a(n)=3-k(n), where k=A000002=Kolakoski sequence; also the sequence of runlengths of a is k.

Original entry on oeis.org

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

Views

Author

Keywords

Comments

The anti-Kolakoski sequence: a(n) never equals the length of the n-th run. Start with a(1)=2, then the first run is of length 1 and a(2)=1; thus the 2nd run is of length 2 and a(3)=1, thus a(4)=a(5)=2, etc. - Jean-Christophe Hervé, Nov 10 2014

Crossrefs

Cf. A088569 (essentially the same sequence).

Programs

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

A054350 Triangular array whose rows are successive generations of the Kolakoski sequence A000002.

Original entry on oeis.org

1, 1, 2, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 1, 1, 2, 2, 1, 1, 2, 1, 2, 2, 1, 2, 1, 2, 2, 1, 1, 2, 1, 2, 2, 1, 2, 2, 1, 1, 2, 1, 1, 2, 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, 1, 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, 1, 1, 2, 1, 1, 2, 1, 2, 2, 1, 2, 2, 1, 1, 2, 1
Offset: 0

Views

Author

N. J. A. Sloane, May 07 2000

Keywords

Examples

			Triangle begins:
1;
1, 2;
1, 2, 2, 1;
1, 2, 2, 1, 1, 2, 1;
1, 2, 2, 1, 1, 2, 1, 2, 2, 1, 2;
1, 2, 2, 1, 1, 2, 1, 2, 2, 1, 2, 2, 1, 1, 2, 1, 1, 2;
...
		

Crossrefs

Row lengths give A054352.

Extensions

More terms from Antonio G. Astudillo (afg_astudillo(AT)lycos.com), Apr 05 2003
Previous Showing 31-40 of 297 results. Next