%I #11 Jul 21 2024 12:48:31
%S 0,0,1,0,6,21,114,597,3278,18420,105618,615331,3632352,21678975,
%T 130598887,793085742,4849791942,29838388707,184573315170,
%U 1147219365762,7161284719412,44876343104655,282206695488603,1780341161583746,11264338644455334,71461150894269030
%N Number of ternary paths of length 3*n having exactly 2 hills.
%H Naiomi Cameron and J. E. McLeod, <a href="https://cs.uwaterloo.ca/journals/JIS/VOL19/McLeod/mcleod3.html">Returns and Hills on Generalized Dyck Paths</a>, Journal of Integer Sequences, Vol. 19, 2016, #16.6.1.
%F a(n) = Sum_{k=0..n-2} (-1)^k * (k+1)*(k+2)*(k+3)/(2*(2*n-1-k)) * binomial(3*n-4-2*k,n-2-k).
%F G.f.: x^2 * (g/(1 + x*g))^3, where g = 1 + x*g^3.
%o (PARI) a(n) = sum(k=0, n-2, (-1)^k*(k+1)*(k+2)*(k+3)/(2*(2*n-1-k))*binomial(3*n-4-2*k, n-2-k));
%Y Column k=2 of A101371.
%Y Cf. A001764, A023053, A294527.
%K nonn
%O 0,5
%A _Seiichi Manyama_, Jul 21 2024