OFFSET
0,4
COMMENTS
The original definition was equivalent to: Let S(n) = sum_{i=0..n} a(i), then n^2+a(n)-S(n+1) = S(n-2). This in turn simplifies to the present definition.
LINKS
Harvey P. Dale, Table of n, a(n) for n = 0..1000
Index entries for linear recurrences with constant coefficients, signature (3,-4,4,-3,1).
FORMULA
a(n) = (n^2 - 1 + (-1)^floor(n/2) * A000034(n))/2.
G.f.: x*(-1+2*x+x^3-4*x^2) / ( (x^2+1)*(x-1)^3 ).
a(2^(n+1)) = A081654(n). - Anton Zakharov, Sep 13 2016
MAPLE
A000034 := proc(n) op(1+(n mod 2), [1, 2]) ; end proc:
MATHEMATICA
LinearRecurrence[{3, -4, 4, -3, 1}, {0, 1, 1, 3, 8}, 60] (* Jean-François Alcover, Mar 30 2020 *)
Join[{0}, RecurrenceTable[{a[1]==a[2]==1, a[n+1]==n^2-a[n-1]}, a, {n, 60}]] (* Harvey P. Dale, Jan 05 2023 *)
PROG
(Python)
print(0, end=', ') # a(-1)=0
prpr = prev = 1 # a(0)=a(1)=1
for n in range(2, 77):
print(prpr, end=', ')
curr = n*n - prpr # a(n) = n^2 - a(n-2)
prpr = prev
prev = curr
# from Alex Ratushnyak, Aug 05 2012
(PARI) a(n) = (n^2-1+(-1)^(n\2)*(1 + (n % 2)))/2; \\ Michel Marcus, Sep 11 2016
CROSSREFS
KEYWORD
nonn
AUTHOR
Benjamin Coinsin, Mar 04 2011
EXTENSIONS
Edited by N. J. A. Sloane, Mar 09 2011
More terms from Alex Ratushnyak, Aug 05 2012
STATUS
approved