login
A187093
a(0)=0, a(1)=a(2)=1; thereafter, a(n+1) = n^2 - a(n-1).
3
0, 1, 1, 3, 8, 13, 17, 23, 32, 41, 49, 59, 72, 85, 97, 111, 128, 145, 161, 179, 200, 221, 241, 263, 288, 313, 337, 363, 392, 421, 449, 479, 512, 545, 577, 611, 648, 685, 721, 759, 800, 841, 881, 923, 968, 1013, 1057, 1103, 1152, 1201, 1249, 1299, 1352, 1405, 1457
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.
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:
A187093 := proc(n) (n^2-1+(-1)^floor(n/2)*A000034(n))/2 ; end proc: # R. J. Mathar
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
Sequence in context: A310303 A022807 A292655 * A081766 A152676 A197062
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