Use FindGeneratingFunctionFindGeneratingFunction
and SeriesCoefficientSeriesCoefficient
:
In[1]:= FindGeneratingFunction[{15, 15, 15, 15, 17, 17, 17, 17, 19, 19, 19, 19, 21, 21, 21, 21, 23, 23, 23, 23}, x]
FindGeneratingFunction[
{15, 15, 15, 15, 17, 17, 17, 17, 19, 19, 19, 19, 21, 21, 21, 21, 23, 23, 23, 23}, x]
Out[1]= (15 - 13x^4)/((-1 + x)^2(1 + x + x^2 + x^3))
(15 - 13*x^4)/((-1 + x)^2*(1 + x + x^2 + x^3))
The formula:
In[2]:= FullSimplify[SeriesCoefficient[%, {x, 0, n}], Element[n, Integers] && n >= 0]
FullSimplify[SeriesCoefficient[%, {x, 0, n}], Element[n, Integers] && n >= 0]
Out[2]= (1/4)(57 + (-1)^n + 2n + 2Cos[(nPi)/2] + 2Sin[(nPi)/2])
(1/4)*(57 + (-1)^n + 2*n + 2*Cos[(n*Pi)/2] + 2*Sin[(n*Pi)/2])
Verification:
In[3]:= Table[%, {n, 0, 30}]
Table[%, {n, 0, 30}]
Out[3]= {15, 15, 15, 15, 17, 17, 17, 17, 19, 19, 19, 19, 21, 21, 21, 21, 23, 23, 23, 23, 25, 25, 25, 25, 27, 27, 27, 27, 29, 29, 29}
{15, 15, 15, 15, 17, 17, 17, 17, 19, 19, 19, 19, 21, 21, 21, 21,
23, 23, 23, 23, 25, 25, 25, 25, 27, 27, 27, 27, 29, 29, 29}