login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A371410
Row sums of A371409: sums of the positions of right parentheses in the properly nested string of parentheses encoded by A063171(n).
2
2, 6, 7, 12, 13, 13, 14, 15, 20, 21, 21, 22, 23, 21, 22, 22, 23, 24, 23, 24, 25, 26, 30, 31, 31, 32, 33, 31, 32, 32, 33, 34, 33, 34, 35, 36, 31, 32, 32, 33, 34, 32, 33, 33, 34, 35, 34, 35, 36, 37, 33, 34, 34, 35, 36, 35, 36, 37, 38, 36, 37, 38, 39, 40, 42, 43, 43, 44, 45, 43
OFFSET
1,1
COMMENTS
See A370220 and A371409 for more information.
REFERENCES
Donald E. Knuth, The Art of Computer Programming, Vol. 4A: Combinatorial Algorithms, Part 1, Addison-Wesley, 2011, Section 7.2.1.6, pp. 440-444.
MATHEMATICA
zlist[m_] := With[{r = 2*Range[2, m]}, Reverse[Map[Join[{1}, #] &, Select[Subsets[Range[2, 2*m-1], {m-1}], Min[r-#] > 0 &]]]];
Table[Delete[Map[Total[Complement[Range[2*m], #]] &, zlist[m]], 0], {m, 5}] (* Paolo Xausa, Mar 25 2024 *)
(* 2nd program: uses Algorithm Z from Knuth's TAOCP section 7.2.1.6, exercise 2 *)
zlist[m_] := Block[{z = 2*Range[m] - 1, j},
Reap[
While[True,
Sow[z];
If[z[[m-1]] < z[[m]] - 1,
z[[m]]--,
j = m - 1; z[[m]] = 2*m - 1;
While[j > 1 && z[[j-1]] == z[[j]] - 1, z[[j]] = 2*j - 1; j--];
If[j == 1, Break[]];
z[[j]]--]
]][[2]][[1]]];
Join[{2}, Table[Delete[Map[Total[Complement[Range[2*m], #]] &, zlist[m]], 0], {m, 2, 5}]] (* Paolo Xausa, Mar 25 2024 *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Paolo Xausa, Mar 22 2024
STATUS
approved