OFFSET
1,2
LINKS
Karl-Heinz Hofmann, Table of n, a(n) for n = 1..10000
Karl-Heinz Hofmann, Examples of a(1..18)
Project Euler, Problem 28. Number spiral diagonals
Index entries for linear recurrences with constant coefficients, signature (2,0,-2,2,-2,0,2,-1).
FORMULA
G.f.: -(x^7 - 2*x^6 + x^4 - x^3 + 2*x^2 - 2*x-1)/((x - 1)^4 * (x + 1)^2 * (x^2 +1)).
a(n) = (24 + 20*n + 6*n^2 + n^3) / 24 for n even.
a(n) = (12 + 17*n + 6*n^2 + n^3) / 24 for n odd and n (mod 4) == 3.
a(n) = (17*n + 6*n^2 + n^3) / 24 for n odd and n (mod 4) == 1.
a(2*n) = A006527(n+1).
a(2*n-1) = A208995(n) - 1.
E.g.f.: ((30 + 45*x + 12*x^2 + x^3)*cosh(x) + (51 + 42*x + 12*x^2 + x^3)*sinh(x) - 6*cos(x))/24. - Stefano Spezia, Aug 19 2022
EXAMPLE
See the PDF in links.
MATHEMATICA
CoefficientList[Series[-(x^7 - 2*x^6 + x^4 - x^3 + 2*x^2 - 2*x - 1)/((x - 1)^4*(x + 1)^2*(x^2 + 1)), {x, 0, 50}], x] (* Amiram Eldar, Aug 19 2022 *)
PROG
(Python)
def A355759(n): # polynomial way.
if n % 2 == 0: return((24 + 20*n + 6*n**2 + n**3)//24)
elif n % 4 == 3: return((12 + 17*n + 6*n**2 + n**3)//24)
elif n % 4 == 1: return(( 17*n + 6*n**2 + n**3)//24)
(PARI) a(n) = (n^2 + 6*n + if(n%2, 17, 20))*n \ 24 + (n%4!=1); \\ Kevin Ryde, Aug 19 2022
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Karl-Heinz Hofmann, Aug 14 2022
STATUS
approved