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”).

The number of length n sequences on {0,1,2} such that there are an equal number of 0's and 1's or there are an equal number of 0's and 2's.
1

%I #15 Aug 12 2017 10:37:41

%S 1,2,6,8,38,102,192,786,2214,4598,17906,51306,112928,425882,1232454,

%T 2818458,10393254,30269862,71152482,257993706,754758738,1811628498,

%U 6482271054,19026456246,46431160992,164353672602,483626452302,1196266880906,4196480707814

%N The number of length n sequences on {0,1,2} such that there are an equal number of 0's and 1's or there are an equal number of 0's and 2's.

%H Alois P. Heinz, <a href="/A235320/b235320.txt">Table of n, a(n) for n = 0..1000</a>

%F For n congruent to 0 mod 3 a(n) = 2*A002426(n) - n!/floor(n/3)!^3.

%F For n congruent to 1 or 2 mod 3 a(n) = 2*A002426(n).

%e a(3) = 8 because we have: 012, 021, 102, 111, 120, 201, 210, 222.

%p a:= proc(n) option remember; `if`(n<6, [1, 2, 6, 8, 38, 102][n+1],

%p ((n-1)^2*(380713*n^2-2450435*n+3831534) *a(n-1)

%p -3*(n-2)^2*(230459*n^2-1671772*n+2280969) *a(n-2)

%p -(811908*n^4-11125602*n^3+47672874*n^2-84737610*n+54621270) *a(n-3)

%p -27*(n-2)*(n-3)*(380713*n^2-2450435*n+3831534) *a(n-4)

%p +81*(n-3)*(n-4)*(230459*n^2-1671772*n+2280969) *a(n-5)

%p +243*(n-3)*(n-4)*(n-5)*(120233*n-220828) *a(n-6)) /

%p (n^2*(n-1)*(10007*n+17779)))

%p end:

%p seq(a(n), n=0..40); # _Alois P. Heinz_, Jan 05 2014

%t Table[2Sum[Multinomial[k,k,n-2k],{k,0,Floor[n/2]}],{n,0,30}]-Riffle[Riffle[Table[Multinomial[n,n,n],{n,0,10}],0],0,3]

%Y Cf. A002426 comment by _Dennis P. Walsh_.

%K nonn,easy

%O 0,2

%A _Geoffrey Critzer_, Jan 05 2014