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 11-20 of 36 results. Next

A358135 Difference of first and last parts of the n-th composition in standard order.

Original entry on oeis.org

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

Views

Author

Gus Wiseman, Oct 31 2022

Keywords

Comments

The k-th composition in standard order (graded reverse-lexicographic, A066099) is obtained by taking the set of positions of 1's in the reversed binary expansion of k, prepending 0, taking first differences, and reversing again. This gives a bijective correspondence between nonnegative integers and integer compositions.

Crossrefs

See link for sequences related to standard compositions.
The first and last parts are A065120 and A001511.
This is the first minus last part of row n of A066099.
The version for Heinz numbers of partitions is A243055.
Row sums of A358133.
The partial sums of standard compositions are A358134, adjusted A242628.
A011782 counts compositions.
A333766 and A333768 give max and min in standard compositions, diff A358138.
A351014 counts distinct runs in standard compositions.

Programs

  • Mathematica
    stc[n_]:=Differences[Prepend[Join @@ Position[Reverse[IntegerDigits[n,2]],1],0]]//Reverse;
    Table[-First[stc[n]]+Last[stc[n]],{n,1,100}]

Formula

a(n) = A001511(n) - A065120(n).

A357187 First differences A357186 = "Take the k-th composition in standard order for each part k of the n-th composition in standard order, then add up everything.".

Original entry on oeis.org

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

Views

Author

Gus Wiseman, Sep 28 2022

Keywords

Comments

Are there any terms > 1?
The k-th composition in standard order (graded reverse-lexicographic, A066099) is obtained by taking the set of positions of 1's in the reversed binary expansion of k, prepending 0, taking first differences, and reversing again. This gives a bijective correspondence between nonnegative integers and integer compositions.

Examples

			We have A357186(5) - A357186(4) = 3 - 2 = 1, so a(4) = 1.
		

Crossrefs

See link for sequences related to standard compositions.
Positions of first appearances appear to all belong to A052955.
Differences of A357186 (row-sums of A357135).
The version for partitions is A357458, differences of A325033.

Programs

  • Mathematica
    stc[n_]:=Differences[Prepend[Join @@ Position[Reverse[IntegerDigits[n,2]],1],0]]//Reverse;
    Differences[Table[stc/@stc[n]/.List->Plus,{n,0,100}]]

Formula

a(n) = A357186(n + 1) - A357186(n).

A374993 Total cost when the elements of the n-th composition (in standard order) are requested from a self-organizing list initialized to (1, 2, 3, ...), using the transpose updating strategy.

Original entry on oeis.org

0, 1, 2, 2, 3, 4, 3, 3, 4, 4, 3, 5, 4, 5, 4, 4, 5, 5, 6, 5, 5, 5, 6, 6, 5, 5, 4, 6, 5, 6, 5, 5, 6, 6, 6, 6, 5, 7, 7, 6, 6, 8, 4, 6, 7, 8, 7, 7, 6, 6, 7, 6, 6, 6, 7, 7, 6, 6, 5, 7, 6, 7, 6, 6, 7, 7, 7, 7, 8, 8, 7, 7, 7, 7, 8, 8, 6, 8, 8, 7, 7, 8, 6, 10, 6, 6, 7
Offset: 0

Views

Author

Pontus von Brömssen, Jul 27 2024

Keywords

Comments

The cost of a request equals the position of the requested element in the list.
After a request, the requested element is transposed with the immediately preceding element (unless the requested element is already at the front of the list).

Examples

			For n=931 (the smallest n for which A374992(n), A374994(n), A374995(n), and a(n) are all distinct), the 931st composition is (1, 1, 2, 4, 1, 1), giving the following development of the list:
   list   | position of requested element
  --------+------------------------------
  1 2 3 4 |         1
  ^       |
  1 2 3 4 |         1
  ^       |
  1 2 3 4 |         2
    ^     |
  2 1 3 4 |         4
        ^ |
  2 1 4 3 |         2
    ^     |
  1 2 4 3 |         1
  ^       |
  ---------------------------------------
          a(931) = 11
		

References

  • D. E. Knuth, The Art of Computer Programming, Vol. 3, 2nd edition, Addison-Wesley, 1998, pp. 401-403.

Crossrefs

Row n=1 of A374996.
Analogous sequences for other updating strategies: A374992, A374994, A374995.
Cf. A000120, A025480, A066099 (compositions in standard order), A333766, A374998.

Programs

  • Python
    def comp(n):
        # see A357625
        return
    def A374993(n):
        if n<1: return 0
        cost,c = 0,comp(n)
        m = list(range(1,max(c)+1))
        for i in c:
            j = m.index(i)
            cost += j+1
            if j > 0:
                m.insert(j-1,m.pop(j))
        return cost # John Tyler Rascoe, Aug 02 2024

Formula

The sum of a(j) over all j such that A000120(j) = k (number of requests) and A333766(j) <= m (upper bound on the requested elements) equals m^k * k * (m+1)/2. This is a consequence of the fact that the first m positions of the list are occupied by the elements 1, ..., m, as long as no element larger than m has been requested so far.
a(n) = a(A025480(n-1)) + A374998(n) for n >= 1.

A374996 Square array read by antidiagonals: T(n,k) is the total cost when the elements of the k-th composition (in standard order) are requested from a self-organizing list initialized to (1, 2, 3, ...), using the move-ahead(n) updating strategy; n, k >= 0.

Original entry on oeis.org

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

Views

Author

Pontus von Brömssen, Jul 27 2024

Keywords

Comments

The cost of a request equals the position of the requested element in the list.
After a request, the requested element is moved n steps closer to the front of the list (or to the front if the element is already less than n steps from the front).

Examples

			Array begins:
  n\k| 0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15
  ---+-----------------------------------------------
   0 | 0  1  2  2  3  3  3  3  4  4  4  4  4  4  4  4
   1 | 0  1  2  2  3  4  3  3  4  4  3  5  4  5  4  4
   2 | 0  1  2  2  3  4  3  3  4  5  3  5  4  5  4  4
   3 | 0  1  2  2  3  4  3  3  4  5  3  5  4  5  4  4
   4 | 0  1  2  2  3  4  3  3  4  5  3  5  4  5  4  4
   5 | 0  1  2  2  3  4  3  3  4  5  3  5  4  5  4  4
   6 | 0  1  2  2  3  4  3  3  4  5  3  5  4  5  4  4
   7 | 0  1  2  2  3  4  3  3  4  5  3  5  4  5  4  4
   8 | 0  1  2  2  3  4  3  3  4  5  3  5  4  5  4  4
   9 | 0  1  2  2  3  4  3  3  4  5  3  5  4  5  4  4
  10 | 0  1  2  2  3  4  3  3  4  5  3  5  4  5  4  4
  11 | 0  1  2  2  3  4  3  3  4  5  3  5  4  5  4  4
  12 | 0  1  2  2  3  4  3  3  4  5  3  5  4  5  4  4
  13 | 0  1  2  2  3  4  3  3  4  5  3  5  4  5  4  4
  14 | 0  1  2  2  3  4  3  3  4  5  3  5  4  5  4  4
  15 | 0  1  2  2  3  4  3  3  4  5  3  5  4  5  4  4
		

Crossrefs

Cf. A000120, A025480, A029837 (row n=0), A374993 (row n=1), A333766, A374992, A375001.

Programs

  • Python
    def comp(n):
        # see A357625
        return
    def A374996(n,k):
        if k<1: return 0
        cost,c = 0,comp(k)
        m = list(range(1,max(c)+1))
        for i in c:
            j = m.index(i)
            cost += j+1
            jp = 0
            if j >= n:
                jp += j-n
            m.insert(jp,m.pop(j))
        return cost # John Tyler Rascoe, Aug 02 2024

Formula

T(n,k) = A374992(k) if n >= A333766(k)-1.
The sum of T(n,k) over all k such that A000120(k) = j (number of requests) and A333766(k) <= m (upper bound on the requested elements) equals m^j * j * (m+1)/2. This is a consequence of the fact that the first m positions of the list are occupied by the elements 1, ..., m, as long as no element larger than m has been requested so far.
T(n,k) = T(n,A025480(k-1)) + A375001(n,k) for n >= 0 and k >= 1.

A349155 Numbers k such that the k-th composition in standard order has sum equal to negative twice its reverse-alternating sum.

Original entry on oeis.org

0, 9, 130, 135, 141, 153, 177, 193, 225, 2052, 2059, 2062, 2069, 2074, 2079, 2089, 2098, 2103, 2109, 2129, 2146, 2151, 2157, 2169, 2209, 2242, 2247, 2253, 2265, 2289, 2369, 2434, 2439, 2445, 2457, 2481, 2529, 2561, 2689, 2818, 2823, 2829, 2841, 2865, 2913
Offset: 1

Views

Author

Gus Wiseman, Nov 22 2021

Keywords

Comments

The k-th composition in standard order (graded reverse-lexicographic, A066099) is obtained by taking the set of positions of 1's in the reversed binary expansion of k, prepending 0, taking first differences, and reversing again. This gives a bijective correspondence between nonnegative integers and integer compositions.
The reverse-alternating sum of a sequence (y_1,...,y_k) is Sum_i (-1)^(k-i) y_i.

Examples

			The terms and corresponding compositions begin:
     0: ()
     9: (3,1)
   130: (6,2)
   135: (5,1,1,1)
   141: (4,1,2,1)
   153: (3,1,3,1)
   177: (2,1,4,1)
   193: (1,6,1)
   225: (1,1,5,1)
  2052: (9,3)
  2059: (8,2,1,1)
  2062: (8,1,1,2)
  2069: (7,2,2,1)
  2074: (7,1,2,2)
  2079: (7,1,1,1,1,1)
  2089: (6,2,3,1)
  2098: (6,1,3,2)
  2103: (6,1,2,1,1,1)
		

Crossrefs

These compositions are counted by A224274 up to 0's.
An unordered version is A348617, counted by A001523 up to 0's.
The positive version is A349153, unreversed A348614.
The unreversed version is A349154.
Positive unordered unreversed: A349159, counted by A000712 up to 0's.
A positive unordered version is A349160, counted by A006330 up to 0's.
A003242 counts Carlitz compositions.
A011782 counts compositions.
A025047 counts alternating or wiggly compositions, complement A345192.
A034871, A097805, and A345197 count compositions by alternating sum.
A103919 counts partitions by alternating sum, reverse A344612.
A116406 counts compositions with alternating sum >=0, ranked by A345913.
A138364 counts compositions with alternating sum 0, ranked by A344619.
Statistics of standard compositions:
- The compositions themselves are the rows of A066099.
- Number of parts is given by A000120, distinct A334028.
- Sum and product of parts are given by A070939 and A124758.
- Maximum and minimum parts are given by A333766 and A333768.
- Heinz number is given by A333219.
Classes of standard compositions:
- Partitions and strict partitions are ranked by A114994 and A333256.
- Multisets and sets are ranked by A225620 and A333255.
- Strict and constant compositions are ranked by A233564 and A272919.
- Carlitz compositions are ranked by A333489, complement A348612.
- Alternating compositions are ranked by A345167, complement A345168.

Programs

  • Mathematica
    stc[n_]:=Differences[Prepend[ Join@@Position[Reverse[IntegerDigits[n,2]],1],0]]//Reverse;
    sats[y_]:=Sum[(-1)^(i-Length[y])*y[[i]],{i,Length[y]}];
    Select[Range[0,1000],Total[stc[#]]==-2*sats[stc[#]]&]

A374992 Total cost when the elements of the n-th composition (in standard order) are requested from a self-organizing list initialized to (1, 2, 3, ...), using the move-to-front updating strategy.

Original entry on oeis.org

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

Views

Author

Pontus von Brömssen, Jul 27 2024

Keywords

Comments

The cost of a request equals the position of the requested element in the list.
After a request, the requested element is moved to the front of the list.

Examples

			For n=931 (the smallest n for which A374993(n), A374994(n), A374995(n), and a(n) are all distinct), the 931st composition is (1, 1, 2, 4, 1, 1), giving the following development of the list:
   list   | position of requested element
  --------+------------------------------
  1 2 3 4 |         1
  ^       |
  1 2 3 4 |         1
  ^       |
  1 2 3 4 |         2
    ^     |
  2 1 3 4 |         4
        ^ |
  4 2 1 3 |         3
      ^   |
  1 4 2 3 |         1
  ^       |
  ---------------------------------------
          a(931) = 12
		

References

  • D. E. Knuth, The Art of Computer Programming, Vol. 3, 2nd edition, Addison-Wesley, 1998, pp. 401-403.

Crossrefs

Analogous sequences for other updating strategies: A374993, A374994, A374995, A374996.
Cf. A000120, A025480, A066099 (compositions in standard order), A333766, A374997.

Formula

a(n) = A374996(k,n) whenever k >= A333766(n)-1.
The sum of a(j) over all j such that A000120(j) = k (number of requests) and A333766(j) <= m (upper bound on the requested elements) equals m^k * k * (m+1)/2. This is a consequence of the fact that the first m positions of the list are occupied by the elements 1, ..., m, as long as no element larger than m has been requested so far.
a(n) = a(A025480(n-1)) + A374997(n) for n >= 1.

A374997 Position of the last requested element when the elements of the n-th composition (in standard order) are requested from a self-organizing list initialized to (1, 2, 3, ...), using the move-to-front updating strategy.

Original entry on oeis.org

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

Views

Author

Pontus von Brömssen, Jul 27 2024

Keywords

Comments

See A374992 for details.

Crossrefs

Analogous sequences for other updating strategies: A374998, A374999, A375000, A375001.
Cf. A025480, A066099 (compositions in standard order), A333766, A374992.

Formula

a(n) = A374992(n) - A374992(A025480(n-1)).
a(n) = A375001(k,n) whenever k >= A333766(n)-1.
Sum_{j=1..m} a(n*2^j+2^(j-1)) = m*(m+1)/2 if m >= A333766(n). This is a consequence of the fact that the first m positions of the list are occupied by the elements 1, ..., m, as long as no element larger than m has been requested so far.

A374998 Position of the last requested element when the elements of the n-th composition (in standard order) are requested from a self-organizing list initialized to (1, 2, 3, ...), using the transpose updating strategy.

Original entry on oeis.org

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

Views

Author

Pontus von Brömssen, Jul 27 2024

Keywords

Comments

See A374993 for details.

Crossrefs

Row n=1 of A375001.
Analogous sequences for other updating strategies: A374997, A374999, A375000.
Cf. A025480, A066099 (compositions in standard order), A333766, A374993.

Formula

a(n) = A374993(n) - A374993(A025480(n-1)).
Sum_{j=1..m} a(n*2^j+2^(j-1)) = m*(m+1)/2 if m >= A333766(n). This is a consequence of the fact that the first m positions of the list are occupied by the elements 1, ..., m, as long as no element larger than m has been requested so far.

A349154 Numbers k such that the k-th composition in standard order has sum equal to negative twice its alternating sum.

Original entry on oeis.org

0, 12, 160, 193, 195, 198, 204, 216, 240, 2304, 2561, 2563, 2566, 2572, 2584, 2608, 2656, 2752, 2944, 3074, 3077, 3079, 3082, 3085, 3087, 3092, 3097, 3099, 3102, 3112, 3121, 3123, 3126, 3132, 3152, 3169, 3171, 3174, 3180, 3192, 3232, 3265, 3267, 3270, 3276
Offset: 1

Views

Author

Gus Wiseman, Nov 21 2021

Keywords

Comments

The k-th composition in standard order (graded reverse-lexicographic, A066099) is obtained by taking the set of positions of 1's in the reversed binary expansion of k, prepending 0, taking first differences, and reversing again. This gives a bijective correspondence between nonnegative integers and integer compositions.
The alternating sum of a sequence (y_1,...,y_k) is Sum_i (-1)^(i-1) y_i.

Examples

			The terms and corresponding compositions begin:
       0: ()
      12: (1,3)
     160: (2,6)
     193: (1,6,1)
     195: (1,5,1,1)
     198: (1,4,1,2)
     204: (1,3,1,3)
     216: (1,2,1,4)
     240: (1,1,1,5)
    2304: (3,9)
    2561: (2,9,1)
    2563: (2,8,1,1)
    2566: (2,7,1,2)
    2572: (2,6,1,3)
    2584: (2,5,1,4)
		

Crossrefs

These compositions are counted by A224274 up to 0's.
Except for 0, a subset of A345919.
The positive version is A348614, reverse A349153.
An unordered version is A348617, counted by A001523.
The reverse version is A349155.
A positive unordered version is A349159, counted by A000712 up to 0's.
A000346 = even-length compositions with alt sum != 0, complement A001700.
A003242 counts Carlitz compositions.
A011782 counts compositions.
A025047 counts alternating or wiggly compositions, complement A345192.
A034871, A097805, and A345197 count compositions by alternating sum.
A103919 counts partitions by sum and alternating sum (reverse: A344612).
A116406 counts compositions with alternating sum >=0, ranked by A345913.
A138364 counts compositions with alternating sum 0, ranked by A344619.
Statistics of standard compositions:
- The compositions themselves are the rows of A066099.
- Number of parts is given by A000120, distinct A334028.
- Sum and product of parts are given by A070939 and A124758.
- Maximum and minimum parts are given by A333766 and A333768.
Classes of standard compositions:
- Partitions and strict partitions are ranked by A114994 and A333256.
- Multisets and sets are ranked by A225620 and A333255.
- Strict and constant compositions are ranked by A233564 and A272919.
- Carlitz compositions are ranked by A333489, complement A348612.
- Necklaces are ranked by A065609, dual A333764, reversed A333943.
- Alternating compositions are ranked by A345167, complement A345168.

Programs

  • Mathematica
    ats[y_]:=Sum[(-1)^(i-1)*y[[i]],{i,Length[y]}];
    stc[n_]:=Differences[Prepend[Join@@Position[Reverse[IntegerDigits[n,2]],1],0]]//Reverse;
    Select[Range[0,1000],Total[stc[#]]==-2*ats[stc[#]]&]

A357180 First run-length of the n-th composition in standard order.

Original entry on oeis.org

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

Views

Author

Gus Wiseman, Sep 24 2022

Keywords

Comments

A composition of n is a finite sequence of positive integers summing to n. The k-th composition in standard order (graded reverse-lexicographic, A066099) is obtained by taking the set of positions of 1's in the reversed binary expansion of k, prepending 0, taking first differences, and reversing again. This gives a bijective correspondence between nonnegative integers and integer compositions.

Examples

			Composition 87 in standard order is (2,2,1,1,1), so a(87) = 2.
		

Crossrefs

See link for sequences related to standard compositions.
For parts instead of run-lengths we have A065120, last A001511.
The version for Heinz numbers of partitions is A067029, last A071178.
This is the first part of row n of A333769.
For minimal instead of first we have A357138, maximal A357137.
The last instead of first run-length is A357181.
A051903 gives maximal part in prime signature.
A061395 gives maximal prime index.
A124767 counts runs in standard compositions.
A286470 gives maximal difference of prime indices.
A333766 gives maximal part of standard compositions, minimal A333768.
A353847 ranks run-sums of standard compositions.

Programs

  • Mathematica
    stc[n_]:=Differences[Prepend[Join@@Position[Reverse[IntegerDigits[n,2]],1],0]]//Reverse;
    Table[If[n==0,0,First[Length/@Split[stc[n]]]],{n,0,100}]
Previous Showing 11-20 of 36 results. Next