A124762 Number of levels for compositions in standard order.
0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 1, 1, 0, 0, 1, 3, 0, 0, 0, 1, 0, 1, 0, 2, 0, 0, 1, 1, 1, 1, 2, 4, 0, 0, 0, 1, 1, 0, 0, 2, 0, 0, 2, 2, 0, 0, 1, 3, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 2, 2, 2, 3, 5, 0, 0, 0, 1, 0, 0, 0, 2, 0, 1, 1, 1, 0, 0, 1, 3, 0, 0, 0, 1, 1, 2, 1, 3, 0, 0, 1, 1, 1, 1, 2, 4, 0, 0, 0, 1, 1, 0, 0, 2, 0
Offset: 0
Examples
Composition number 11 is 2,1,1; 2>1=1, so a(11) = 1. The table starts: 0 0 0 1 0 0 0 2 0 0 1 1 0 0 1 3 0 0 0 1 0 1 0 2 0 0 1 1 1 1 2 4 0 0 0 1 1 0 0 2 0 0 2 2 0 0 1 3 0 0 0 1 0 1 0 2 1 1 2 2 2 2 3 5
Crossrefs
Anti-runs summing to n are counted by A003242(n).
A triangle counting maximal anti-runs of compositions is A106356.
A triangle counting maximal runs of compositions is A238279.
Partitions whose first differences are an anti-run are A238424.
All of the following pertain to compositions in standard order (A066099):
- Weakly decreasing runs are counted by A124765.
- Weakly increasing runs are counted by A124766.
- Equal runs are counted by A124767.
- Strictly increasing runs are counted by A124768.
- Strictly decreasing runs are counted by A124769.
- Strict compositions are A233564.
- Constant compositions are A272919.
- Normal compositions are A333217.
- Adjacent unequal pairs are counted by A333382.
- Anti-runs are A333489.
Programs
-
Mathematica
stc[n_]:=Differences[Prepend[Join@@Position[Reverse[IntegerDigits[n,2]],1],0]]//Reverse; Table[Length[Select[Partition[stc[n],2,1],SameQ@@#&]],{n,0,100}] (* Gus Wiseman, Apr 08 2020 *)
Formula
For a composition b(1),...,b(k), a(n) = Sum_{1<=i=1
For n > 0, a(n) = A333381(n) - 1. - Gus Wiseman, Apr 08 2020
A345167 Numbers k such that the k-th composition in standard order is alternating.
0, 1, 2, 4, 5, 6, 8, 9, 12, 13, 16, 17, 18, 20, 22, 24, 25, 32, 33, 34, 38, 40, 41, 44, 45, 48, 49, 50, 54, 64, 65, 66, 68, 70, 72, 76, 77, 80, 81, 82, 88, 89, 96, 97, 98, 102, 108, 109, 128, 129, 130, 132, 134, 140, 141, 144, 145, 148, 152, 153, 160, 161, 162
Offset: 1
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.
A sequence is alternating if it is alternately strictly increasing and strictly decreasing, starting with either. For example, the partition (3,2,2,2,1) has no alternating permutations, even though it does have the anti-run permutations (2,3,2,1,2) and (2,1,2,3,2).
Examples
The terms together with their binary indices begin: 1: (1) 25: (1,3,1) 66: (5,2) 2: (2) 32: (6) 68: (4,3) 4: (3) 33: (5,1) 70: (4,1,2) 5: (2,1) 34: (4,2) 72: (3,4) 6: (1,2) 38: (3,1,2) 76: (3,1,3) 8: (4) 40: (2,4) 77: (3,1,2,1) 9: (3,1) 41: (2,3,1) 80: (2,5) 12: (1,3) 44: (2,1,3) 81: (2,4,1) 13: (1,2,1) 45: (2,1,2,1) 82: (2,3,2) 16: (5) 48: (1,5) 88: (2,1,4) 17: (4,1) 49: (1,4,1) 89: (2,1,3,1) 18: (3,2) 50: (1,3,2) 96: (1,6) 20: (2,3) 54: (1,2,1,2) 97: (1,5,1) 22: (2,1,2) 64: (7) 98: (1,4,2) 24: (1,4) 65: (6,1) 102: (1,3,1,2)
Links
- Wikipedia, Alternating permutation
Crossrefs
The complement is A345168.
Factorizations with a permutation of this type: A348379.
A003242 counts anti-run compositions.
A345164 counts alternating permutations of prime indices.
Statistics of standard compositions:
- Length is A000120.
- Constant runs are A124767.
- Heinz number is A333219.
- Number of maximal anti-runs is A333381.
- Runs-resistance is A333628.
- Number of distinct parts is A334028.
Classes of standard compositions:
- Weakly decreasing compositions (partitions) are A114994.
- Weakly increasing compositions (multisets) are A225620.
- Anti-runs are A333489.
- Non-alternating anti-runs are A345169.
Programs
-
Mathematica
stc[n_]:=Differences[Prepend[Join@@Position[ Reverse[IntegerDigits[n,2]],1],0]]//Reverse; wigQ[y_]:=Or[Length[y]==0,Length[Split[y]] ==Length[y]&&Length[Split[Sign[Differences[y]]]]==Length[y]-1]; Select[Range[0,100],wigQ@*stc]
A007305 Numerators of Farey (or Stern-Brocot) tree fractions.
0, 1, 1, 1, 2, 1, 2, 3, 3, 1, 2, 3, 3, 4, 5, 5, 4, 1, 2, 3, 3, 4, 5, 5, 4, 5, 7, 8, 7, 7, 8, 7, 5, 1, 2, 3, 3, 4, 5, 5, 4, 5, 7, 8, 7, 7, 8, 7, 5, 6, 9, 11, 10, 11, 13, 12, 9, 9, 12, 13, 11, 10, 11, 9, 6, 1, 2, 3, 3, 4, 5, 5, 4, 5, 7, 8, 7, 7, 8, 7, 5, 6, 9, 11, 10, 11, 13, 12, 9, 9, 12, 13, 11
Offset: 0
Comments
From Yosu Yurramendi, Jun 25 2014: (Start)
If the terms (n>0) are written as an array (left-aligned fashion) with rows of length 2^m, m = 0,1,2,3,...
1,
1,2,
1,2,3,3,
1,2,3,3,4,5,5,4,
1,2,3,3,4,5,5,4,5,7,8,7,7,8,7,5,
1,2,3,3,4,5,5,4,5,7,8,7,7,8,7,5,6,9,11,10,11,13,12,9,9,12,13,11,10,11,9,6,
then the sum of the m-th row is 3^m (m = 0,1,2,), each column k is constant, and the constants are from A007306, denominators of Farey (or Stern-Brocot) tree fractions (see formula).
If the rows are written in a right-aligned fashion:
1,
1,2,
1, 2,3,3,
1, 2, 3, 3, 4, 5,5,4,
1,2, 3, 3, 4, 5, 5,4,5, 7, 8, 7, 7, 8,7,5,
1,2,3,3,4,5,5,4,5,7,8,7,7,8,7,5,6,9,11,10,11,13,12,9,9,12,13,11,10,11,9,6,
then each column is an arithmetic sequence. The differences of the arithmetic sequences also give the sequence A007306 (see formula). The first terms of columns are from A007305 itself (a(A004761(n+1)) = a(n), n>0), and the second ones from A049448 (a(A004761(n+1)+2^A070941(n)) = A049448(n), n>0). (End)
If the sequence is considered in blocks of length 2^m, m = 0,1,2,..., the blocks are the reverse of the blocks of A047679: (a(2^m+1+k) = A047679(2^(m+1)-2-k), m = 0,1,2,..., k = 0,1,2,...,2^m-1). - Yosu Yurramendi, Jun 30 2014
Examples
A007305/A007306 = [ 0/1; 1/1; ] 1/2; 1/3, 2/3; 1/4, 2/5, 3/5, 3/4; 1/5, 2/7, 3/8, 3/7, 4/7, 5/8, 5/7, 4/5, ... Another version of Stern-Brocot is A007305/A047679 = 1, 2, 1/2, 3, 1/3, 3/2, 2/3, 4, 1/4, 4/3, 3/4, 5/2, 2/5, 5/3, 3/5, 5, 1/5, 5/4, 4/5, ...
References
- R. L. Graham, D. E. Knuth and O. Patashnik, Concrete Mathematics. Addison-Wesley, Reading, MA, 1990, p. 117.
- G. H. Hardy and E. M. Wright, An Introduction to the Theory of Numbers. 3rd ed., Oxford Univ. Press, 1954, p. 23.
- J. C. Lagarias, Number Theory and Dynamical Systems, pp. 35-72 of S. A. Burr, ed., The Unreasonable Effectiveness of Number Theory, Proc. Sympos. Appl. Math., 46 (1992). Amer. Math. Soc.
- W. J. LeVeque, Topics in Number Theory. Addison-Wesley, Reading, MA, 2 vols., 1956, Vol. 1, p. 154.
- I. Niven and H. S. Zuckerman, An Introduction to the Theory of Numbers. 2nd ed., Wiley, NY, 1966, p. 141.
- N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
Links
- T. D. Noe, Table of n, a(n) for n=0..4096
- A. Bogomolny, Stern-Brocot Tree
- A. Bogomolny, Inspiration for Maple code
- A. Brocot, Calcul des rouages par approximation, nouvelle méthode, Revue Chonométrique 3, 186-194, 1861.
- G. A. Jones, The Farey graph, Séminaire Lotharingien de Combinatoire, B18e (1987), 2 pp.
- Shin-ichi Katayama, Modified Farey trees and Pythagorean triples, Journal of mathematics, the University of Tokushima, 47, 2013.
- G. Melançon, Lyndon factorization of sturmian words, Discr. Math., 210 (2000), 137-149.
- Hugo Pfoertner, Ratio A007305(n)/A007306(n) vs n, using Plot 2.
- N. J. A. Sloane, Stern-Brocot or Farey Tree
- Noam Zimhoni, A forest of Eisensteinian triplets, arXiv:1904.11782 [math.NT], 2019.
- Index entries for fraction trees
- Index entries for sequences related to Stern's sequences
Programs
-
Maple
A007305 := proc(n) local b; b := proc(n) option remember; local msb, r; if n < 3 then return 1 fi; msb := ilog2(n); r := n - 2^msb; if ilog2(r) = msb - 1 then b(r) + b(3*2^(msb-1) - r - 1) else b(2^(msb - 1) + r) fi end: if n = 0 then 0 else b(n-1) fi end: # Antti Karttunen, Mar 19 2000 [Corrected and rewritten by Peter Luschny, Apr 24 2024] seq(A007305(n), n = 0..92);
-
Mathematica
sbt[n_] := Module[{R,L,Y}, R={{1,0},{1,1}}; L={{1,1},{0,1}}; Y={{1,0},{0,1}}; w[b_] := Fold[ #1.If[ #2 == 0,L,R] &,Y,b]; u[a_] := {a[[2,1]]+a[[2,2]],a[[1,1]]+a[[1,2]]}; Map[u,Map[w,Tuples[{0,1},n]]]] A007305(n) = Flatten[Append[{0,1},Table[Map[First,sbt[i]],{i,0,5}]]] A047679(n) = Flatten[Table[Map[Last,sbt[i]],{i,0,5}]] (* Peter Luschny, Apr 27 2009 *)
-
R
a <- 1 for(m in 1:6) for(k in 0:(2^(m-1)-1)) { a[2^m+ k] <- a[2^(m-1)+k] a[2^m+2^(m-1)+k] <- a[2^(m-1)+k] + a[2^m-k-1] } a # Yosu Yurramendi, Jun 25 2014
Formula
a(n) = SternBrocotTreeNum(n-1) # n starting from 2 gives the sequence from 1, 1, 2, 1, 2, 3, 3, 1, 2, 3, 3, 4, 5, 5, 4, 1, ...
From Reinhard Zumkeller, Dec 22 2008: (Start)
For n > 1: a(n+2) = if A025480(n-1) != 0 and A025480(n) != 0 then a(A025480(n-1)+2) + a(A025480(n)+2) else if A025480(n)=0 then a(A025480(n-1)+2)+1 else 0 + a(A025480(n-1)+2).
From Yosu Yurramendi, Jun 25 2014: (Start)
For m = 1,2,3,..., and k = 0,1,2,...,2^(m-1)-1, with a(1)=1:
a(2^m+k) = a(2^(m-1)+k);
a(2^m+2^(m-1)+k) = a(2^(m-1)+k) + a(2^m-k-1). (End)
a(2^(m+2)-k) = A007306(2^(m+1)-k), m=0,1,2,..., k=0,1,2,...,2^m-1. - Yosu Yurramendi, Jul 04 2014
a(2^(m+1)+2^m+k) - a(2^m+k) = A007306(2^m-k+1), m=1,2,..., k=1,2,...,2^(m-1). - Yosu Yurramendi, Jul 05 2014
From Yosu Yurramendi, Jan 01 2015: (Start)
a(2^m+2^q-1) = q+1, q = 0, 1, 2,..., m = q, q+1, q+2,...
a(2^m+2^q) = q+2, q = 0, 1, 2,..., m = q+1, q+2, q+3,... (End)
a(2^m+k) = A007306(k+1), m >= 0, 0 <= k < 2*m. - Yosu Yurramendi, May 20 2019
A333382 Number of adjacent unequal parts in the n-th composition in standard-order.
0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 2, 1, 0, 0, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 2, 1, 2, 1, 0, 0, 1, 1, 1, 0, 2, 2, 1, 1, 2, 0, 1, 2, 3, 2, 1, 1, 2, 2, 2, 2, 2, 3, 2, 1, 2, 1, 2, 1, 2, 1, 0, 0, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 2, 2, 3, 2, 1, 1, 2, 2, 2, 1, 1, 2
Offset: 0
Keywords
Comments
A composition of n is a finite sequence of positive integers summing to n. The k-th composition in standard order (row k of 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.
For n > 0, a(n) is one fewer than the number of maximal runs of the n-th composition in standard-order.
Examples
The 46th composition in standard order is (2,1,1,2), with maximal runs ((2),(1,1),(2)), so a(46) = 3 - 1 = 2.
Links
- Wikipedia, Longest increasing subsequence
Crossrefs
Indices of first appearances (not counting 0) are A113835.
Partitions whose 0-appended first differences are a run are A007862.
Partitions whose first differences are a run are A049988.
A triangle counting maximal anti-runs of compositions is A106356.
A triangle counting maximal runs of compositions is A238279.
All of the following pertain to compositions in standard order (A066099):
- Adjacent equal pairs are counted by A124762.
- Weakly decreasing runs are counted by A124765.
- Weakly increasing runs are counted by A124766.
- Equal runs are counted by A124767.
- Strictly increasing runs are counted by A124768.
- Strictly decreasing runs are counted by A124769.
- Strict compositions are ranked by A233564.
- Constant compositions are ranked by A272919.
- Normal compositions are ranked by A333217.
- Anti-runs are ranked by A333489.
- Anti-runs are counted by A333381.
Programs
-
Mathematica
stc[n_]:=Differences[Prepend[Join@@Position[Reverse[IntegerDigits[n,2]],1],0]]//Reverse; Table[Length[Select[Partition[stc[n],2,1],UnsameQ@@#&]],{n,0,100}]
Formula
For n > 0, a(n) = A124767(n) - 1.
A344618 Reverse-alternating sums of standard compositions (A066099). Alternating sums of the compositions ranked by A228351.
0, 1, 2, 0, 3, -1, 1, 1, 4, -2, 0, 2, 2, 0, 2, 0, 5, -3, -1, 3, 1, 1, 3, -1, 3, -1, 1, 1, 3, -1, 1, 1, 6, -4, -2, 4, 0, 2, 4, -2, 2, 0, 2, 0, 4, -2, 0, 2, 4, -2, 0, 2, 2, 0, 2, 0, 4, -2, 0, 2, 2, 0, 2, 0, 7, -5, -3, 5, -1, 3, 5, -3, 1, 1, 3, -1, 5, -3, -1, 3
Offset: 0
Comments
Up to sign, same as A124754.
The reverse-alternating sum of a sequence (y_1,...,y_k) is Sum_i (-1)^(k-i) y_i.
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
The sequence of nonnegative integers together with the corresponding standard compositions and their reverse-alternating sums begins: 0: () -> 0 15: (1111) -> 0 30: (1112) -> 1 1: (1) -> 1 16: (5) -> 5 31: (11111) -> 1 2: (2) -> 2 17: (41) -> -3 32: (6) -> 6 3: (11) -> 0 18: (32) -> -1 33: (51) -> -4 4: (3) -> 3 19: (311) -> 3 34: (42) -> -2 5: (21) -> -1 20: (23) -> 1 35: (411) -> 4 6: (12) -> 1 21: (221) -> 1 36: (33) -> 0 7: (111) -> 1 22: (212) -> 3 37: (321) -> 2 8: (4) -> 4 23: (2111) -> -1 38: (312) -> 4 9: (31) -> -2 24: (14) -> 3 39: (3111) -> -2 10: (22) -> 0 25: (131) -> -1 40: (24) -> 2 11: (211) -> 2 26: (122) -> 1 41: (231) -> 0 12: (13) -> 2 27: (1211) -> 1 42: (222) -> 2 13: (121) -> 0 28: (113) -> 3 43: (2211) -> 0 14: (112) -> 2 29: (1121) -> -1 44: (213) -> 4 Triangle begins (row lengths A011782): 0 1 2 0 3 -1 1 1 4 -2 0 2 2 0 2 0 5 -3 -1 3 1 1 3 -1 3 -1 1 1 3 -1 1 1
Crossrefs
Up to sign, same as the reverse version A124754.
The version for Heinz numbers of partitions is A344616.
Positions of zeros are A344619.
A116406 counts compositions with alternating sum >= 0.
A344610 counts partitions by sum and positive reverse-alternating sum.
A344611 counts partitions of 2n with reverse-alternating sum >= 0.
All of the following pertain to compositions in standard order:
- The length is A000120.
- Converting to reversed ranking gives A059893.
- The rows are A066099.
- The sum is A070939.
- The runs are counted by A124767.
- The reversed version is A228351.
- Strict compositions are ranked by A233564.
- Constant compositions are ranked by A272919.
- The Heinz number is A333219.
- Anti-run compositions are ranked by A333489.
Programs
-
Mathematica
sats[y_]:=Sum[(-1)^(i-Length[y])*y[[i]],{i,Length[y]}]; stc[n_]:=Reverse[Differences[Prepend[Join@@Position[Reverse[IntegerDigits[n,2]],1],0]]] Table[sats[stc[n]],{n,0,100}]
A344619 The a(n)-th composition in standard order (A066099) has alternating sum 0.
0, 3, 10, 13, 15, 36, 41, 43, 46, 50, 53, 55, 58, 61, 63, 136, 145, 147, 150, 156, 162, 165, 167, 170, 173, 175, 180, 185, 187, 190, 196, 201, 203, 206, 210, 213, 215, 218, 221, 223, 228, 233, 235, 238, 242, 245, 247, 250, 253, 255, 528, 545, 547, 550, 556, 568
Offset: 1
Keywords
Comments
The alternating sum of a sequence (y_1,...,y_k) is Sum_i (-1)^(i-1) y_i.
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
The sequence of terms together with the corresponding compositions begins: 0: () 3: (1,1) 10: (2,2) 13: (1,2,1) 15: (1,1,1,1) 36: (3,3) 41: (2,3,1) 43: (2,2,1,1) 46: (2,1,1,2) 50: (1,3,2) 53: (1,2,2,1) 55: (1,2,1,1,1) 58: (1,1,2,2) 61: (1,1,1,2,1) 63: (1,1,1,1,1,1) 136: (4,4) 145: (3,4,1) 147: (3,3,1,1) 150: (3,2,1,2) 156: (3,1,1,3)
Crossrefs
These are the positions of zeros in A344618.
A116406 counts compositions with alternating sum >= 0.
A124754 gives the alternating sum of standard compositions.
A316524 is the alternating sum of the prime indices of n.
A344604 counts wiggly compositions with twins.
A344610 counts partitions by sum and positive reverse-alternating sum.
A344611 counts partitions of 2n with reverse-alternating sum >= 0.
A344616 gives the alternating sum of reversed prime indices.
All of the following pertain to compositions in standard order:
- The length is A000120.
- Converting to reversed ranking gives A059893.
- The rows are A066099.
- The sum is A070939.
- The runs are counted by A124767.
- The reversed version is A228351.
- Strict compositions are ranked by A233564.
- Constant compositions are ranked by A272919.
- The Heinz number is A333219.
- Anti-run compositions are ranked by A333489.
Programs
-
Mathematica
ats[y_]:=Sum[(-1)^(i-1)*y[[i]],{i,Length[y]}]; stc[n_]:=Reverse[Differences[Prepend[Join@@Position[Reverse[IntegerDigits[n,2]],1],0]]] Select[Range[0,100],ats[stc[#]]==0&]
A345168 Numbers k such that the k-th composition in standard order is not alternating.
3, 7, 10, 11, 14, 15, 19, 21, 23, 26, 27, 28, 29, 30, 31, 35, 36, 37, 39, 42, 43, 46, 47, 51, 52, 53, 55, 56, 57, 58, 59, 60, 61, 62, 63, 67, 69, 71, 73, 74, 75, 78, 79, 83, 84, 85, 86, 87, 90, 91, 92, 93, 94, 95, 99, 100, 101, 103, 104, 105, 106, 107, 110
Offset: 1
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.
A sequence is alternating if it is alternately strictly increasing and strictly decreasing, starting with either. For example, the partition (3,2,2,2,1) has no alternating permutations, even though it does have the anti-run permutations (2,3,2,1,2) and (2,1,2,3,2).
Examples
The sequence of terms together with their binary indices begins: 3: (1,1) 35: (4,1,1) 59: (1,1,2,1,1) 7: (1,1,1) 36: (3,3) 60: (1,1,1,3) 10: (2,2) 37: (3,2,1) 61: (1,1,1,2,1) 11: (2,1,1) 39: (3,1,1,1) 62: (1,1,1,1,2) 14: (1,1,2) 42: (2,2,2) 63: (1,1,1,1,1,1) 15: (1,1,1,1) 43: (2,2,1,1) 67: (5,1,1) 19: (3,1,1) 46: (2,1,1,2) 69: (4,2,1) 21: (2,2,1) 47: (2,1,1,1,1) 71: (4,1,1,1) 23: (2,1,1,1) 51: (1,3,1,1) 73: (3,3,1) 26: (1,2,2) 52: (1,2,3) 74: (3,2,2) 27: (1,2,1,1) 53: (1,2,2,1) 75: (3,2,1,1) 28: (1,1,3) 55: (1,2,1,1,1) 78: (3,1,1,2) 29: (1,1,2,1) 56: (1,1,4) 79: (3,1,1,1,1) 30: (1,1,1,2) 57: (1,1,3,1) 83: (2,3,1,1) 31: (1,1,1,1,1) 58: (1,1,2,2) 84: (2,2,3)
Links
- Wikipedia, Alternating permutation
Crossrefs
The complement is A345167.
These compositions are counted by A345192.
A003242 counts anti-run compositions.
A344604 counts alternating compositions with twins.
Statistics of standard compositions:
- Length is A000120.
- Constant runs are A124767.
- Heinz number is A333219.
- Number of maximal anti-runs is A333381.
- Runs-resistance is A333628.
- Number of distinct parts is A334028.
Classes of standard compositions:
- Weakly decreasing compositions (partitions) are A114994.
- Weakly increasing compositions (multisets) are A225620.
- Strict compositions are A233564.
- Constant compositions are A272919.
- Anti-run compositions are A333489.
- Non-anti-run compositions are A348612.
Programs
-
Mathematica
stc[n_]:=Differences[Prepend[Join@@Position[Reverse[IntegerDigits[n,2]],1],0]]//Reverse; wigQ[y_]:=Or[Length[y]==0,Length[Split[y]]==Length[y]&&Length[Split[Sign[Differences[y]]]]==Length[y]-1]; Select[Range[0,100],Not@*wigQ@*stc]
A047679 Denominators in full Stern-Brocot tree.
1, 2, 1, 3, 3, 2, 1, 4, 5, 5, 4, 3, 3, 2, 1, 5, 7, 8, 7, 7, 8, 7, 5, 4, 5, 5, 4, 3, 3, 2, 1, 6, 9, 11, 10, 11, 13, 12, 9, 9, 12, 13, 11, 10, 11, 9, 6, 5, 7, 8, 7, 7, 8, 7, 5, 4, 5, 5, 4, 3, 3, 2, 1, 7, 11, 14, 13, 15, 18, 17, 13, 14, 19, 21, 18, 17, 19, 16, 11, 11, 16, 19, 17, 18
Offset: 0
Comments
Numerators are A007305.
Write n in binary; list run lengths; add 1 to last run length; make into continued fraction. Sequence gives denominator of fraction obtained.
From Reinhard Zumkeller, Dec 22 2008: (Start)
For n > 1: a(n) = if A025480(n-1) != 0 and A025480(n) != 0 then = a(A025480(n-1)) + a(A025480(n)) else if A025480(n)=0 then a(A025480(n-1))+0 else 1+a(A025480(n-1));
From Yosu Yurramendi, Jun 25 2014 and Jun 30 2014: (Start)
If the terms are written as an array a(m, k) = a(2^(m-1)-1+k) with m >= 1 and k = 0, 1, ..., 2^(m-1)-1:
1,
2,1,
3,3, 2, 1,
4,5, 5, 4, 3, 3, 2,1,
5,7, 8, 7, 7, 8, 7,5,4, 5, 5, 4, 3, 3,2,1,
6,9,11,10,11,13,12,9,9,12,13,11,10,11,9,6,5,7,8,7,7,8,7,5,4,5,5,4,3,3,2,1,
then the sum of the m-th row is 3^(m-1), and each column is an arithmetic sequence. The differences of these arithmetic sequences give the sequence A007306(k+1). The first terms of columns are 1 for k = 0 and a(k-1) for k >= 1.
In a row reversed version A(m, k) = a(m, m-(k+1)):
1
1,2
1,2,3,3,
1,2,3,3,4,5,5,4
1,2,3,3,4,5,5,4,5,7,8,7,7,8,7,5
1,2,3,3,4,5,5,4,5,7,8,7,7,8,7,5,6,9,11,10,11,13,12,12,9,9,12,13,11,10,11,9,6
each column k >= 0 is constant, namely A007306(k+1).
This row reversed version coincides with the array for A007305 (see the Jun 25 2014 comment there). (End)
Looking at the plot, the sequence clearly shows a fractal structure. (The repeating pattern oddly resembles the [first completed] facade of the Sagrada Familia!) - Daniel Forgues, Nov 15 2019
Examples
E.g., 57->111001->[ 3,2,1 ]->[ 3,2,2 ]->3 + 1/(2 + 1/(2) ) = 17/2. For n=1,2, ... we get 2, 3/2, 3, 4/3, 5/3, 5/2, 4, 5/4, 7/5, 8/5, ... 1; 2,1; 3,3,2,1; 4,5,5,4,3,3,2,1; .... Another version of Stern-Brocot is A007305/A047679 = 1, 2, 1/2, 3, 1/3, 3/2, 2/3, 4, 1/4, 4/3, 3/4, 5/2, 2/5, 5/3, 3/5, 5, 1/5, 5/4, 4/5, ...
Links
Programs
-
Mathematica
CFruns[ n_Integer ] := Fold[ #2+1/#1&, Infinity, Reverse[ MapAt[ #+1&, Length/@Split[ IntegerDigits[ n, 2 ] ], {-1} ] ] ] (* second program: *) a[n_] := Module[{LL = Length /@ Split[IntegerDigits[n, 2]]}, LL[[-1]] += 1; FromContinuedFraction[LL] // Denominator]; Table[a[n], {n, 1, 100}] (* Jean-François Alcover, Feb 25 2016 *)
-
PARI
{a(n) = local(v, w); v = binary(n++); w = [1]; for( n=2, #v, if( v[n] != v[n-1], w = concat(w, 1), w[#w]++)); w[#w]++; contfracpnqn(w)[2, 1]} /* Michael Somos, Jul 22 2011 */
-
R
a <- 1 for(m in 1:6) for(k in 0:(2^(m-1)-1)) { a[2^m+ k] = a[2^(m-1)+k] + a[2^m-k-1] a[2^m+2^(m-1)+k] = a[2^(m-1)+k] } a # Yosu Yurramendi, Dec 31 2014
Formula
a(n) = SternBrocotTreeDen(n) # n starting from 1.
From Yosu Yurramendi, Jul 02 2014: (Start)
For m >0 and 0 <= k < 2^(m-1), with a(0)=1, a(1)=2:
a(2^m+k-1) = a(2^(m-1)+k-1) + a((2^m-1)-k-1);
a(2^m+2^(m-1)+k-1) = a(2^(m-1)+k-1). (End)
a(2^m-2^q ) = q+1, q >= 0, m > q
a(2^m-2^q-1) = q+2, q >= 0, m > q+1. - Yosu Yurramendi, Jan 01 2015
a(2^(m+1)-1-k) = A007306(k+1), m >= 0, 0 <= k <= 2^m. - Yosu Yurramendi, May 20 2019
Extensions
Edited by Wolfdieter Lang, Mar 31 2015
A374515 Irregular triangle read by rows where row n lists the leaders of anti-runs in the n-th composition in standard order.
1, 2, 1, 1, 3, 2, 1, 1, 1, 1, 4, 3, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 4, 3, 3, 1, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6, 5, 4, 4, 1, 3, 3, 3, 3, 3, 1, 1, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 1, 2, 1, 1, 1, 1, 1, 1
Offset: 0
Comments
Anti-runs summing to n are counted by A003242(n).
The leaders of anti-runs in a sequence are obtained by splitting it into maximal consecutive anti-runs (sequences with no adjacent equal terms) and taking the first term of each.
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
The maximal anti-runs of the 1234567th composition in standard order are ((3,2,1,2),(2,1,2,5,1),(1),(1)), so row 1234567 is (3,2,1,1). The nonnegative integers, corresponding compositions, and leaders of anti-runs begin: 0: () -> () 15: (1,1,1,1) -> (1,1,1,1) 1: (1) -> (1) 16: (5) -> (5) 2: (2) -> (2) 17: (4,1) -> (4) 3: (1,1) -> (1,1) 18: (3,2) -> (3) 4: (3) -> (3) 19: (3,1,1) -> (3,1) 5: (2,1) -> (2) 20: (2,3) -> (2) 6: (1,2) -> (1) 21: (2,2,1) -> (2,2) 7: (1,1,1) -> (1,1,1) 22: (2,1,2) -> (2) 8: (4) -> (4) 23: (2,1,1,1) -> (2,1,1) 9: (3,1) -> (3) 24: (1,4) -> (1) 10: (2,2) -> (2,2) 25: (1,3,1) -> (1) 11: (2,1,1) -> (2,1) 26: (1,2,2) -> (1,2) 12: (1,3) -> (1) 27: (1,2,1,1) -> (1,1) 13: (1,2,1) -> (1) 28: (1,1,3) -> (1,1) 14: (1,1,2) -> (1,1) 29: (1,1,2,1) -> (1,1)
Links
Crossrefs
Row-leaders of nonempty rows are A065120.
Row-lengths are A333381.
Row-sums are A374516.
A106356 counts compositions by number of maximal anti-runs.
A238279 counts compositions by number of maximal runs
A238424 counts partitions whose first differences are an anti-run.
All of the following pertain to compositions in standard order:
- Length is A000120.
- Sum is A029837(n+1).
- Parts are listed by A066099.
Six types of maximal runs:
Programs
-
Mathematica
stc[n_]:=Differences[Prepend[Join @@ Position[Reverse[IntegerDigits[n,2]],1],0]]//Reverse; Table[First/@Split[stc[n],UnsameQ],{n,0,100}]
A372429 Sum of binary indices of prime(n). Sum of positions of ones in the reversed binary expansion of prime(n).
2, 3, 4, 6, 7, 8, 6, 8, 11, 13, 15, 10, 11, 13, 16, 15, 18, 19, 10, 13, 12, 17, 15, 17, 14, 17, 19, 20, 21, 19, 28, 11, 13, 15, 17, 19, 21, 17, 20, 22, 22, 23, 29, 16, 19, 21, 23, 30, 24, 25, 26, 31, 27, 33, 10, 15, 17, 19, 18, 19, 21, 19, 23, 26, 25, 28, 23
Offset: 1
Comments
A binary index of n is any position of a 1 in its reversed binary expansion. The binary indices of n are row n of A048793.
Do 2, 3, 4, 7, 12, 14 appear just once?
Are 1, 5, 9 missing?
The above questions hold true up to n = 10^6. - John Tyler Rascoe, May 21 2024
Examples
The primes together with their binary expansions and binary indices begin: 2: 10 ~ {2} 3: 11 ~ {1,2} 5: 101 ~ {1,3} 7: 111 ~ {1,2,3} 11: 1011 ~ {1,2,4} 13: 1101 ~ {1,3,4} 17: 10001 ~ {1,5} 19: 10011 ~ {1,2,5} 23: 10111 ~ {1,2,3,5} 29: 11101 ~ {1,3,4,5} 31: 11111 ~ {1,2,3,4,5} 37: 100101 ~ {1,3,6} 41: 101001 ~ {1,4,6} 43: 101011 ~ {1,2,4,6} 47: 101111 ~ {1,2,3,4,6} 53: 110101 ~ {1,3,5,6} 59: 111011 ~ {1,2,4,5,6} 61: 111101 ~ {1,3,4,5,6} 67: 1000011 ~ {1,2,7} 71: 1000111 ~ {1,2,3,7} 73: 1001001 ~ {1,4,7} 79: 1001111 ~ {1,2,3,4,7}
Links
- John Tyler Rascoe, Table of n, a(n) for n = 1..9438
Crossrefs
The number instead of sum of binary indices is A014499.
Row-sums of A372471.
A056239 adds up prime indices.
A070939 gives length of binary expansion.
A096111 gives product of binary indices.
A326031 gives weight of the set-system with BII-number n.
A372427 lists numbers whose binary and prime indices have the same sum.
Programs
-
Mathematica
bix[n_]:=Join@@Position[Reverse[IntegerDigits[n,2]],1]; Table[Total[bix[Prime[n]]],{n,100}]
Formula
a(n) = A029931(prime(n)).
Comments