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-8 of 8 results.

A238343 Triangle T(n,k) read by rows: T(n,k) is the number of compositions of n with k descents, n>=0, 0<=k<=n.

Original entry on oeis.org

1, 1, 0, 2, 0, 0, 3, 1, 0, 0, 5, 3, 0, 0, 0, 7, 9, 0, 0, 0, 0, 11, 19, 2, 0, 0, 0, 0, 15, 41, 8, 0, 0, 0, 0, 0, 22, 77, 29, 0, 0, 0, 0, 0, 0, 30, 142, 81, 3, 0, 0, 0, 0, 0, 0, 42, 247, 205, 18, 0, 0, 0, 0, 0, 0, 0, 56, 421, 469, 78, 0, 0, 0, 0, 0, 0, 0, 0, 77, 689, 1013, 264, 5, 0, 0, 0, 0, 0, 0, 0, 0, 101, 1113, 2059, 786, 37, 0, 0, 0, 0, 0, 0, 0, 0, 0
Offset: 0

Views

Author

Joerg Arndt and Alois P. Heinz, Feb 25 2014

Keywords

Comments

Counting ascents gives the same triangle.
For n > 0, also the number of compositions of n with k + 1 maximal weakly increasing runs. - Gus Wiseman, Mar 23 2020

Examples

			Triangle starts:
00:    1;
01:    1,    0;
02:    2,    0,    0;
03:    3,    1,    0,    0;
04:    5,    3,    0,    0,   0;
05:    7,    9,    0,    0,   0, 0;
06:   11,   19,    2,    0,   0, 0, 0;
07:   15,   41,    8,    0,   0, 0, 0, 0;
08:   22,   77,   29,    0,   0, 0, 0, 0, 0;
09:   30,  142,   81,    3,   0, 0, 0, 0, 0, 0;
10:   42,  247,  205,   18,   0, 0, 0, 0, 0, 0, 0;
11:   56,  421,  469,   78,   0, 0, 0, 0, 0, 0, 0, 0;
12:   77,  689, 1013,  264,   5, 0, 0, 0, 0, 0, 0, 0, 0;
13:  101, 1113, 2059,  786,  37, 0, 0, 0, 0, 0, 0, 0, 0, 0;
14:  135, 1750, 4021, 2097, 189, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0;
15:  176, 2712, 7558, 5179, 751, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0;
...
From _Gus Wiseman_, Mar 23 2020: (Start)
Row n = 5 counts the following compositions:
  (5)          (3,2)
  (1,4)        (4,1)
  (2,3)        (1,3,1)
  (1,1,3)      (2,1,2)
  (1,2,2)      (2,2,1)
  (1,1,1,2)    (3,1,1)
  (1,1,1,1,1)  (1,1,2,1)
               (1,2,1,1)
               (2,1,1,1)
(End)
		

Crossrefs

T(3n,n) gives A000045(n+1).
T(3n+1,n) = A136376(n+1).
Row sums are A011782.
Compositions by length are A007318.
The version for co-runs or levels is A106356.
The case of partitions (instead of compositions) is A133121.
The version for runs is A238279.
The version without zeros is A238344.
The version for weak ascents is A333213.

Programs

  • Maple
    b:= proc(n, i) option remember; `if`(n=0, 1, expand(
           add(b(n-j, j)*`if`(j (p-> seq(coeff(p, x, i), i=0..n))(b(n, 0)):
    seq(T(n), n=0..20);
  • Mathematica
    b[n_, i_] := b[n, i] = If[n == 0, 1, Sum[b[n-j, j]*If[jJean-François Alcover, Jan 08 2015, translated from Maple *)
    Table[Length[Select[Join@@Permutations/@IntegerPartitions[n],n==0||Length[Split[#,LessEqual]]==k+1&]],{n,0,9},{k,0,n}] (* Gus Wiseman, Mar 23 2020 *)

Formula

Sum_{k=0..n} k * T(n,k) = A045883(n-2) for n>=2.

A333213 Triangle read by rows where T(n,k) is the number of compositions of n with k adjacent terms that are equal or increasing (weak ascents) n >= 0, 0 <= k <= n.

Original entry on oeis.org

1, 0, 1, 0, 1, 1, 0, 2, 1, 1, 0, 2, 4, 1, 1, 0, 3, 6, 5, 1, 1, 0, 4, 10, 10, 6, 1, 1, 0, 5, 17, 20, 13, 7, 1, 1, 0, 6, 27, 38, 31, 16, 8, 1, 1, 0, 8, 40, 69, 67, 42, 19, 9, 1, 1, 0, 10, 58, 123, 132, 101, 54, 22, 10, 1, 1
Offset: 0

Views

Author

Gus Wiseman, Mar 14 2020

Keywords

Comments

A composition of n is a finite sequence of positive integers summing to n.
Also the number of compositions of n with k + 1 maximal strictly decreasing subsequences.
Also the number of compositions of n with k adjacent terms that are equal or decreasing (weak descents).

Examples

			Triangle begins:
   1
   0   1
   0   1   1
   0   2   1   1
   0   2   4   1   1
   0   3   6   5   1   1
   0   4  10  10   6   1   1
   0   5  17  20  13   7   1   1
   0   6  27  38  31  16   8   1   1
   0   8  40  69  67  42  19   9   1   1
   0  10  58 123 132 101  54  22  10   1   1
   0  12  86 202 262 218 139  67  25  11   1   1
   0  15 121 332 484 467 324 182  81  28  12   1   1
Row n = 6 counts the following compositions:
  (6)    (15)    (114)   (1113)   (11112)  (111111)
  (42)   (24)    (123)   (1122)
  (51)   (33)    (222)   (11121)
  (321)  (132)   (1131)  (11211)
         (141)   (1212)  (12111)
         (213)   (1221)  (21111)
         (231)   (1311)
         (312)   (2112)
         (411)   (2211)
         (2121)  (3111)
		

Crossrefs

Compositions by length are A007318.
The case of reversed partitions (instead of compositions) is A008284.
The version counting equal adjacencies is A106356.
The case of partitions (instead of compositions) is A133121.
The version counting unequal adjacencies is A238279.
The strict/strong version is A238343.

Programs

  • Mathematica
    Table[Length[Select[Join@@Permutations/@IntegerPartitions[n],Length[Split[#,#1>#2&]]==k&]],{n,0,12},{k,0,n}]
  • PARI
    T(n)={my(M=matrix(n+1, n+1)); M[1,1]=x; for(n=1, n, for(k=1, n, M[1+n,1+k] = M[1+n,1+k-1] + x*M[1+n-k, 1+n-k] + (1-x)*M[1+n-k, 1+min(k-1, n-k)])); M[1,1]=1; vector(n+1, i, Vecrev(M[i,i]))}
    { my(A=T(12)); for(i=1, #A, print(A[i])) } \\ Andrew Howroyd, Jan 19 2023

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

A333215 Lengths of maximal weakly increasing subsequences in the sequence of prime gaps (A001223).

Original entry on oeis.org

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

Views

Author

Gus Wiseman, Mar 14 2020

Keywords

Comments

Prime gaps are differences between adjacent prime numbers.

Examples

			The prime gaps split into the following weakly increasing subsequences: (1,2,2,4), (2,4), (2,4,6), (2,6), (4), (2,4,6,6), (2,6), (4), (2,6), (4,6,8), (4), (2,4), (2,4,14), ...
		

Crossrefs

Prime gaps are A001223.
Ones correspond to strong prime quartets A054804.
Weakly increasing runs of compositions in standard order are A124766.
First differences of A258026 (with zero prepended).
The version for the Kolakoski sequence is A332875.
The weakly decreasing version is A333212.
The unequal version is A333216.
Positions of weak ascents in prime gaps are A333230.
The strictly decreasing version is A333252.
The strictly increasing version is A333253.
The equal version is A333254.

Programs

  • Mathematica
    Length/@Split[Differences[Array[Prime,100]],#1<=#2&]//Most

Formula

Ones correspond to strong prime quartets (A054804), so the sum of terms up to but not including the n-th one is A000720(A054804(n - 1)).

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]

A332273 Sizes of maximal weakly decreasing subsequences of A000002.

Original entry on oeis.org

1, 4, 2, 3, 4, 3, 3, 3, 2, 4, 3, 2, 3, 4, 2, 3, 3, 3, 3, 4, 2, 3, 4, 3, 2, 3, 3, 3, 4, 2, 3, 4, 3, 3, 3, 2, 3, 4, 3, 2, 4, 3, 3, 3, 3, 3, 4, 2, 3, 3, 3, 3, 3, 3, 3, 4, 2, 3, 3, 3, 3, 3, 2, 4, 3, 2, 3, 3, 3, 4, 2, 3, 4, 3, 2, 4, 3, 3, 3, 3, 2, 4, 3, 3, 3, 3, 3
Offset: 1

Views

Author

Gus Wiseman, Mar 08 2020

Keywords

Examples

			The weakly decreasing subsequences begin: (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).
		

Crossrefs

The number of runs in the first n terms of A000002 is A156253.
The weakly increasing version is A332875.

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,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];
    Length/@Split[kol[40],#1>=#2&]

Formula

a(n) = A000002(2*n - 2) + A000002(2*n - 1) for n > 1.

A156242 Bisection of A054353.

Original entry on oeis.org

3, 6, 9, 12, 15, 19, 21, 24, 27, 30, 33, 36, 39, 42, 45, 47, 50, 54, 57, 60, 63, 66, 69, 72, 75, 77, 81, 84, 87, 90, 93, 96, 100, 102, 105, 108, 111, 114, 117, 120, 123, 127, 129, 132, 136, 139, 142, 145, 147, 151, 154, 156, 159, 163, 166, 169, 172, 174, 177, 181
Offset: 1

Views

Author

Benoit Cloitre, Feb 07 2009

Keywords

Comments

Positions of strict descents in the Kolakoski sequence A000002. Strict ascents are A156243. - Gus Wiseman, Mar 31 2020

Crossrefs

The version for prime gaps is A258026.
Sizes of maximal weakly increasing subsequences of A000002 are A332875.

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,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];
    Join@@Position[Partition[kol[100],2,1],{2,1}] (* Gus Wiseman, Mar 31 2020 *)

Formula

a(n) = A054353(2n).
A000002(a(n))=2 and A000002(a(n)+1)=1. - Jon Perry, Sep 04 2012

A333229 First sums of the Kolakoski sequence A000002.

Original entry on oeis.org

3, 4, 3, 2, 3, 3, 3, 4, 3, 3, 4, 3, 2, 3, 3, 2, 3, 4, 3, 3, 3, 2, 3, 3, 3, 4, 3, 2, 3, 3, 2, 3, 3, 3, 4, 3, 3, 4, 3, 2, 3, 3, 3, 4, 3, 3, 3, 2, 3, 3, 2, 3, 4, 3, 3, 4, 3, 2, 3, 3, 3, 4, 3, 3, 4, 3, 2, 3, 3, 2, 3, 3, 3, 4, 3, 3, 3, 2, 3, 4, 3, 3, 4, 3, 2, 3, 3
Offset: 1

Views

Author

Gus Wiseman, Mar 18 2020

Keywords

Crossrefs

Positions of 3's are A054353.
Positions of 2's are A074262.
Positions of 4's are A074263.
The number of runs in the first n terms of A000002 is A156253(n).
Even-indexed terms are A332273 (without the first term).
Odd-indexed terms are A332875.

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,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[kol[n][[-1]]+kol[n+1][[-1]],{n,30}]

Formula

a(n) = A000002(n) + A000002(n + 1).
Showing 1-8 of 8 results.