OFFSET
1,2
LINKS
G. C. Greubel, Table of n, a(n) for n = 1..1000
Index entries for linear recurrences with constant coefficients, signature (3,-2,-2,3,-1).
FORMULA
a(n) = (14*n^3 - 3*n^2 + 10*n + 3*mod(n, 2))/24.
G.f.: x*(1 + 2*x + 3*x^2 + x^3)/((1 - x)^4*(1 + x)). - Ilya Gutkovskiy, Jun 17 2016
E.g.f.: (1/48)*( -3*exp(-x) + (3 + 42*x + 78*x^2 + 28*x^3)*exp(x) ). - G. C. Greubel, Oct 19 2023
a(n) ~ 7*n^3/12. - Charles R Greathouse IV, May 31 2026
MATHEMATICA
(* First program *)
T[n_, k_]:= T[n, k]= Which[k==n, n(n-1) + 1, k==n-1, (n-1)^2 + 1, k==1, n + T[n-2, 1], 1 < k < n-1, T[n-1, k+1] + 1, True, 0];
a[n_]:= Sum[T[n, k], {k, 1, n}];
Array[a, 40]
(* second program: *)
LinearRecurrence[{3, -2, -2, 3, -1}, {1, 5, 16, 37, 72}, 50] (* Vincenzo Librandi, Jun 16 2016 *)
PROG
(Magma) [(n*(20-6*n+28*n^2) + 3*(1-(-1)^n))/48: n in [1..40]]; // G. C. Greubel, Oct 19 2023
(SageMath) [(n*(20-6*n+28*n^2) + 6*(n%2))/48 for n in range(1, 41)] # G. C. Greubel, Oct 19 2023
(PARI) a(n)=n*(20-6*n+28*n^2)\/48 \\ Charles R Greathouse IV, May 31 2026
CROSSREFS
KEYWORD
nonn,easy,changed
AUTHOR
Jean-François Alcover and Paul Curtz, Jun 16 2016
STATUS
approved
