%I #6 Mar 14 2026 15:03:54
%S 0,1,1,4,22,138,930,6561,47800,356728,2712758,20944303,163738947,
%T 1293610671,10312170488,82843804507,670045658032,5451693184584,
%U 44591169828366,366447128131373,3024200357007623,25053501077514721,208272200149758543,1736864093227610857
%N G.f. A(x) satisfies (x+1)*A(x)^5-x*A(x)^4-(2x^2+x)*A(x)^3+(2x^3+3x^2)*A(x)^2-3x^3*A(x)+x^4=0.
%C Number of n-vertex planar rooted trees with vertices colored red, blue, and green with red root where red vertices can only be followed by blue vertices, blue vertices can be followed by vertices of any colors, and green vertices can be followed by red or green vertices.
%H Nathan Fox, <a href="/A394140/b394140.txt">Table of n, a(n) for n = 0..300</a>
%H S. Dimitrov, N. Fox, K. Hadaway, A. Tharp, and S. Wagner, <a href="https://arxiv.org/abs/2602.16055">Counting Colored Trees</a>, arXiv:2602.16055 [math.CO], 2026.
%o (Python)
%o def A394140(n):
%o A = [[0, 1, 0], [1, 1, 1], [1, 0, 1]]
%o if n == 0:
%o return 0
%o m = len(A)
%o output = [[1] for i in range(m)]
%o for l in range(2, n + 1):
%o for i in range(m):
%o term = 0
%o for k in range(1, l):
%o for j in range(m):
%o term += A[i][j] * output[i][k - 1] * output[j][l - k - 1]
%o output[i].append(term)
%o return output[0][n - 1]
%Y Cf. A394141, A394142.
%K nonn
%O 0,4
%A _Nathan Fox_, Mar 11 2026