OFFSET
0,3
COMMENTS
The transformation from a Dyck word or well-formed bracket expression into a recurrence formula is defined by the ordered steps, "()" -> "(k)" where k is the number of pairs of outer brackets inclosing the brackets in question, then ")(" -> ")+(", and finally "(" -> "a(".
For k > 1, the first occurrence of k occurs at A155587(k)-1.
EXAMPLE
For n = 53 the 53rd Dyck word in lexicographic order is 1110010010 or ((())())() written as a well-formed bracket expression. The first adjacent pair of closed brackets is twice nested, the second pair once, and the last pair is open; giving (((2))(1))(0). Next "+" is added in between each pair of adjacent opposite brackets ")(", and finally "a" is appended to the left of each right bracket "(", yielding the formula a(53) = a(a(a(2)) + a(1)) + a(0).
The formulas for a(n) begin:
n | n-th Dyck word | a(n)
0 * 1
1 () a(0)
2 ()() a(0)+a(0)
3 (()) a(a(1))
4 ()()() a(0)+a(0)+a(0)
5 ()(()) a(0)+a(a(1))
6 (())() a(a(1))+a(0)
7 (()()) a(a(1)+a(1))
8 ((())) a(a(a(2)))
9 ()()()() a(0)+a(0)+a(0)+a(0)
10 ()()(()) a(0)+a(0)+a(a(1))
...
PROG
(Python)
from itertools import count, islice
from sympy.utilities.iterables import multiset_permutations
def A014486_gen():
return #from Chai Wah Wu, see A014486
def A377168_list(maxn):
A = [1]
D = list(islice(A014486_gen(), maxn+1))
for n in range(1, maxn+1):
c, c2 = 0, 0
y = bin(D[n])[2:].replace("1", "u").replace("0", "v")
z = y
for i in range(1, len(y)):
if y[i] == "u":
c += 1
if y[i-1] == "v":
z = z[:i+c2] + '+' + z[i+c2:]
c2 += 1
else:
if y[i-1] == "u":
z = z[:i+c2] + str(c) + z[i+c2:]
c2 += (len(str(c)))
c -= 1
A.append(eval(z.replace("u", "A[").replace("v", "]")))
return(A)
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
John Tyler Rascoe, Oct 18 2024
STATUS
approved