OFFSET
2,2
LINKS
G. C. Greubel, Table of n, a(n) for n = 2..1000
FORMULA
a(n) = ((7*n^2 - 4*n + 4)*a(n-1) + 2*n*(2*n-1)*a(n-2))/(2*(n-2)*(n+2)), n >= 5. - G. C. Greubel, Jul 01 2024
MATHEMATICA
a[n_]:= a[n]= If[n<5, 4^(n-1) -3^(n-1) +1 -Boole[n==2], ((7*n^2 -4*n + 4)*a[n-1] +2*n*(2*n-1)*a[n-2])/(2*(n-2)*(n+2))];
Table[a[n], {n, 2, 40}] (* G. C. Greubel, Jul 01 2024 *)
PROG
(Magma)
[1] cat [n le 2 select 4^(n+1) -3^(n+1) +1 else ((7*n^2+24*n+24 )*Self(n-1) + 2*(2*n+3)*(n+2)*Self(n-2))/(2*n*(n+4)): n in [1..40]]; // G. C. Greubel, Jul 01 2024
(SageMath)
@CachedFunction
def a(n): # a = A026640
if n<5: return 4^(n-1) -3^(n-1) +1 -int(n==2)
else: return ((7*n^2-4*n+4)*a(n-1) + 2*n*(2*n-1)*a(n-2))/(2*(n-2)*(n+2))
[a(n) for n in range(2, 41)] # G. C. Greubel, Jul 01 2024
CROSSREFS
KEYWORD
nonn
AUTHOR
STATUS
approved