OFFSET
2,2
LINKS
Colin Barker, Table of n, a(n) for n = 2..1000
Index entries for linear recurrences with constant coefficients, signature (2,0,-2,1).
FORMULA
a(2) = 1; a(3) = 4; for n >= 4, a(n) = 2 + Sum_{i=4..n} d(i), where d(i) = i for even i, d(i) = i-3 for odd i.
From Colin Barker, Jul 12 2015 and Aug 20 2015: (Start)
a(n) = (5+3*(-1)^n-4*n+2*n^2)/4 for n>3.
a(n) = (n^2-2*n+4)/2 for n even and n>3.
a(n) = (n^2-2*n+1)/2 for n odd and n>3.
a(n) = 2*a(n-1)-2*a(n-3)+a(n-4) for n>6.
G.f.: x^2*(2*x^5-5*x^4+2*x^3+2*x^2-2*x-1) / ((x-1)^3*(x+1)).
(End)
MATHEMATICA
Prepend[Table[2 + Sum[If[EvenQ@ i, i, i - 3], {i, 3, n}], {n, 3, 48}], 1] (* Michael De Vlieger, Jul 12 2015 *)
Join[{1, 2, 6, 8, 14, 18}, LinearRecurrence[{2, 0, -2, 1}, {26, 32, 42, 50}, 50]] (* Vincenzo Librandi, Jul 16 2015 *)
PROG
(PARI) a=4; print1("1, ", a, ", "); for (n=4, 100, if (Mod(n, 2)==0, d=n, d=n-3); a=a+d; print1(a, ", "))
(PARI) Vec(x^2*(2*x^5-5*x^4+2*x^3+2*x^2-2*x-1)/((x-1)^3*(x+1)) + O(x^100)) \\ Colin Barker, Jul 12 2015 and Aug 20 2015
(PARI) a(n)=if(n<3, 1, (n^2-2*n)\2+2-(n%2)) \\ Charles R Greathouse IV, Jul 17 2015
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Kival Ngaokrajang, Jul 11 2015
STATUS
approved