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

A354907 Number of distinct sums of contiguous constant subsequences (partial runs) of the n-th composition in standard order.

Original entry on oeis.org

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

Views

Author

Gus Wiseman, Jun 23 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.
Every sequence can be uniquely split into a sequence of non-overlapping runs. For example, the runs of (2,2,1,1,1,3,2,2) are ((2,2),(1,1,1),(3),(2,2)), with sums (4,3,3,4).

Examples

			Composition number 981 in standard order is (1,1,1,2,2,2,1), with partial runs (1), (2), (1,1), (2,2), (1,1,1), (2,2,2), with distinct sums {1,2,3,4,6}, so a(981) = 5.
		

Crossrefs

Positions of 1's are A000051.
Positions of first appearances are A000079.
The standard compositions used here are A066099, run-sums A353847/A353932.
If we allow any subsequence we get A334968.
The case of full runs is A353849, firsts A246534.
A version for nonempty partitions is A353861, full A353835.
Counting all distinct runs (instead of their distinct sums) gives A354582.
A124767 counts runs in standard compositions.
A238279 and A333755 count compositions by number of runs.
A330036 counts distinct partial runs of prime indices, full A005811.
A351014 counts distinct runs of standard compositions, firsts A351015.
A353853-A353859 pertain to composition run-sum trajectory.
A353860 counts collapsible compositions.
A354584 lists run-sums of prime indices, rows ranked by A353832.

Programs

  • Mathematica
    stc[n_]:=Differences[Prepend[Join@@ Position[Reverse[IntegerDigits[n,2]],1],0]]//Reverse;
    pre[y_]:=NestWhileList[Most,y,Length[#]>1&];
    Table[Length[Union[Total/@Join@@pre/@Split[stc[n]]]],{n,0,100}]

A354581 Numbers k such that the k-th composition in standard order is rucksack, meaning every distinct partial run has a different sum.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 15, 16, 17, 18, 19, 20, 21, 22, 24, 25, 26, 28, 31, 32, 33, 34, 35, 36, 37, 38, 40, 41, 42, 44, 45, 48, 49, 50, 51, 52, 53, 54, 56, 57, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 76, 77, 80, 81, 82, 84, 85, 86, 88
Offset: 0

Views

Author

Gus Wiseman, Jun 15 2022

Keywords

Comments

We define a partial run of a sequence to be any contiguous constant subsequence.
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 term rucksack is short for run-knapsack.

Examples

			The terms together with their corresponding compositions begin:
   0: ()
   1: (1)
   2: (2)
   3: (1,1)
   4: (3)
   5: (2,1)
   6: (1,2)
   7: (1,1,1)
   8: (4)
   9: (3,1)
  10: (2,2)
  12: (1,3)
  13: (1,2,1)
  15: (1,1,1,1)
Missing are:
  11: (2,1,1)
  14: (1,1,2)
  23: (2,1,1,1)
  27: (1,2,1,1)
  29: (1,1,2,1)
  30: (1,1,1,2)
  39: (3,1,1,1)
  43: (2,2,1,1)
  46: (2,1,1,2)
		

Crossrefs

The version for binary indices is A000225.
Counting distinct sums of full runs gives A353849, partitions A353835.
For partitions we have A353866, counted by A353864, complement A354583.
These compositions are counted by A354580.
Counting distinct sums of partial runs gives A354907, partitions A353861.
A066099 lists all compositions in standard order.
A124767 counts runs in standard compositions.
A124771 counts distinct contiguous subsequences, non-contiguous A334299.
A238279 and A333755 count compositions by number of runs.
A351014 counts distinct runs in standard compositions, firsts A351015.
A353838 ranks partitions with all distinct run-sums, counted by A353837.
A353851 counts compositions with all equal run-sums, ranked by A353848.
A353852 ranks compositions with all distinct run-sums, counted by A353850.
A353853-A353859 pertain to composition run-sum trajectory.
A353932 lists run-sums of standard compositions, rows ranked by A353847.

Programs

  • Mathematica
    stc[n_]:=Differences[Prepend[Join@@ Position[Reverse[IntegerDigits[n,2]],1],0]]//Reverse;
    Select[Range[0,100],UnsameQ@@Total/@Union@@Subsets/@Split[stc[#]]&]

A330166 Length of the longest run of 0's in the ternary expression of n.

Original entry on oeis.org

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

Views

Author

Joshua Oliver, Dec 04 2019

Keywords

Comments

All numbers appear in this sequence. The n-th power of 3 (A000244(n)) has n 0's in its ternary expression.
The longest run of zeros possible in this sequence is 2, as the last digit of the ternary expression of the integers cycles between 0, 1, and 2, meaning that at least one of three consecutive numbers has a 0 in its ternary expression.

Examples

			For n = 87, the ternary expression of 87 is 10020. The length of the runs of 0's in the ternary expression of 87 are 2 and 1, respectively. The larger of these two values is 2, so a(87) = 2.
   n [ternary n] a(n)
   0 [        0] 1
   1 [        1] 0
   2 [        2] 0
   3 [      1 0] 1
   4 [      1 1] 0
   5 [      1 2] 0
   6 [      2 0] 1
   7 [      2 1] 0
   8 [      2 2] 0
   9 [    1 0 0] 2
  10 [    1 0 1] 1
  11 [    1 0 2] 1
  12 [    1 1 0] 1
  13 [    1 1 1] 0
  14 [    1 1 2] 0
  15 [    1 2 0] 1
  16 [    1 2 1] 0
  17 [    1 2 2] 0
  18 [    2 0 0] 2
  19 [    2 0 1] 1
  20 [    2 0 2] 1
		

Crossrefs

Equals zero iff n is in A032924.

Programs

  • Mathematica
    Table[Max@FoldList[If[#2==0,#1+1,0]&,0,IntegerDigits[n,3]],{n,0,90}]

Formula

a(A000244(n)) = a(3^n) = n.
a(n) = 0 iff n is in A032924.

A330167 Length of the longest run of 1's in the ternary expression of n.

Original entry on oeis.org

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

Views

Author

Joshua Oliver, Dec 04 2019

Keywords

Comments

All numbers appear in this sequence. Numbers of the form (3^n-1)/2 (A003462(n)) have n 1's in their ternary expression.
The longest run of zeros possible in this sequence is 2, as the last digit of the ternary expression of the integers cycles between 0, 1, and 2, meaning that at least one of three consecutive numbers has a 1 in its ternary expression.

Examples

			For n = 43, the ternary expression of 43 is 1121. The length of the runs of 1's in the ternary expression of 43 are 2 and 1, respectively. The larger of these two values is 2, so a(43) = 2.
   n [ternary n] a(n)
   0 [        0] 0
   1 [        1] 1
   2 [        2] 0
   3 [      1 0] 1
   4 [      1 1] 2
   5 [      1 2] 1
   6 [      2 0] 0
   7 [      2 1] 1
   8 [      2 2] 0
   9 [    1 0 0] 1
  10 [    1 0 1] 1
  11 [    1 0 2] 1
  12 [    1 1 0] 2
  13 [    1 1 1] 3
  14 [    1 1 2] 2
  15 [    1 2 0] 1
  16 [    1 2 1] 1
  17 [    1 2 2] 1
  18 [    2 0 0] 0
  19 [    2 0 1] 1
  20 [    2 0 2] 0
		

Crossrefs

Equals zero iff n is in A005823.

Programs

  • Mathematica
    Table[Max@FoldList[If[#2==1,#1+1,0]&,0,IntegerDigits[n,3]],{n,0,90}]
    Table[Max[Length/@Select[Split[IntegerDigits[n,3]],MemberQ[#,1]&]],{n,0,100}]/.(-\[Infinity]->0) (* Harvey P. Dale, Jan 07 2023 *)

Formula

a(A003462(n)) = a((3^n-1)/2) = n.
a(n) = 0 iff n is in A005823.

A330168 Length of the longest run of 2's in the ternary expression of n.

Original entry on oeis.org

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

Views

Author

Joshua Oliver, Dec 04 2019

Keywords

Comments

All numbers appear in this sequence. Numbers of the form 3^n-1 (A024023(n)) have n 2's in their ternary expression.
The longest run of zeros possible in this sequence is 2, as the last digit of the ternary expression of the integers cycles between 0, 1, and 2, meaning that at least one of three consecutive numbers has a 2 in its ternary expression.

Examples

			For n = 74, the ternary expression of 74 is 2202. The length of the runs of 2's in the ternary expression of 74 are 2 and 1, respectively. The larger of these two values is 2, so a(74) = 2.
   n [ternary n] a(n)
   0 [        0] 0
   1 [        1] 0
   2 [        2] 1
   3 [      1 0] 0
   4 [      1 1] 0
   5 [      1 2] 1
   6 [      2 0] 1
   7 [      2 1] 1
   8 [      2 2] 2
   9 [    1 0 0] 0
  10 [    1 0 1] 0
  11 [    1 0 2] 1
  12 [    1 1 0] 0
  13 [    1 1 1] 0
  14 [    1 1 2] 1
  15 [    1 2 0] 1
  16 [    1 2 1] 1
  17 [    1 2 2] 2
  18 [    2 0 0] 1
  19 [    2 0 1] 1
  20 [    2 0 2] 1
		

Crossrefs

Equals zero iff n is in A005836.

Programs

  • Mathematica
    Table[Max@FoldList[If[#2==2,#1+1,0]&,0,IntegerDigits[n,3]],{n,0,90}]

Formula

a(A024023(n)) = a(3^n-1) = n.
a(n) = 0 iff n is in A005836.

A354582 Number of distinct contiguous constant subsequences (or partial runs) in the k-th composition in standard order.

Original entry on oeis.org

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

Views

Author

Gus Wiseman, Jun 13 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.

Examples

			Composition number 981 in standard order is (1,1,1,2,2,2,1), with partial runs (1), (2), (1,1), (2,2), (1,1,1), (2,2,2), so a(981) = 6.
As a triangle:
  1
  1 2
  1 2 2 3
  1 2 2 3 2 2 3 4
  1 2 2 3 2 3 2 4 2 2 3 3 3 3 4 5
  1 2 2 3 2 3 3 4 2 3 3 4 3 2 3 5 2 2 3 3 3 3 2 4 3 3 4 3 4 4 5 6
		

Crossrefs

The version for partitions is A001222, full A001221.
If we allow any constant subsequence we get A063787.
If we allow any contiguous subsequence we get A124771.
Positions of first appearances are A126646.
The version for binary indices is A330036, full A005811.
If we allow any subsequence we get A334299.
The full version is A351014, firsts A351015.
The version for run-sums of partitions is A353861, full A353835.
Counting distinct sums of partial runs gives A354907, full A353849.
A066099 lists all compositions in standard order.
A124767 counts runs in standard compositions.
A238279 and A333755 count compositions by number of runs.
A353852 ranks compositions with all distinct run-sums, counted by A353850.
A353853-A353859 pertain to composition run-sum trajectory.
A353932 lists run-sums of standard compositions, rows ranked by A353847.

Programs

  • Mathematica
    stc[n_]:=Differences[Prepend[Join@@ Position[Reverse[IntegerDigits[n,2]],1],0]]//Reverse;
    pre[y_]:=NestWhileList[Most,y,Length[#]>1&];
    Table[Length[Union[Join@@pre/@Split[stc[n]]]],{n,0,100}]

A332025 Sum of the lengths of the longest runs of 0, 1, and 2 in the ternary expression of n.

Original entry on oeis.org

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

Views

Author

Joshua Oliver, Feb 05 2020

Keywords

Comments

All positive integers appear in this sequence. Given some number k, there will always be some ternary number that has k 1's or k 2's.
The number 0 never appears in this sequence, as every number has at least 1 digit.

Examples

			For n = 268, the ternary expansion of 268 is 100221. The length of the run of 0's in the ternary expansion of 268 is 2. The length of the runs of 1's in the ternary expansion of 268 are 1 and 1 respectively. The length of the run of 2's in the ternary expansion of 268 is 2. The sum of 2, 1, and 2 is 5, so a(268) = 5.
   n [ternary n] A330166(n) + A330167(n) + A330168(n) = a(n)
   0 [        0] 1          + 0          + 0          = 1
   1 [        1] 0          + 1          + 0          = 1
   2 [        2] 0          + 0          + 1          = 1
   3 [      1 0] 1          + 1          + 0          = 2
   4 [      1 1] 0          + 2          + 0          = 2
   5 [      1 2] 0          + 1          + 1          = 2
   6 [      2 0] 1          + 0          + 1          = 2
   7 [      2 1] 0          + 1          + 1          = 2
   8 [      2 2] 0          + 0          + 2          = 2
   9 [    1 0 0] 2          + 1          + 0          = 3
  10 [    1 0 1] 1          + 1          + 0          = 2
  11 [    1 0 2] 1          + 1          + 1          = 3
  12 [    1 1 0] 1          + 2          + 0          = 3
  13 [    1 1 1] 0          + 3          + 0          = 3
  14 [    1 1 2] 0          + 2          + 1          = 3
  15 [    1 2 0] 1          + 1          + 1          = 3
  16 [    1 2 1] 0          + 1          + 1          = 2
  17 [    1 2 2] 0          + 1          + 2          = 3
  18 [    2 0 0] 2          + 0          + 1          = 3
  19 [    2 0 1] 1          + 1          + 1          = 3
  20 [    2 0 2] 1          + 0          + 1          = 2
		

Crossrefs

Programs

  • Mathematica
    Table[Sum[Max@FoldList[If[#2==k,#1+1,0]&,0,IntegerDigits[n,3]],{k,0,2}],{n,1,90}]

Formula

a(n) = A330166(n) + A330167(n) + A330168(n).
a(A003462(n)) = a(A024023(n)) = n.
Showing 1-7 of 7 results.