login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

a(0)=0, a(1)=a(2)=1; thereafter, a(n+1) = n^2 - a(n-1).
3

%I #44 Jan 05 2023 15:49:42

%S 0,1,1,3,8,13,17,23,32,41,49,59,72,85,97,111,128,145,161,179,200,221,

%T 241,263,288,313,337,363,392,421,449,479,512,545,577,611,648,685,721,

%U 759,800,841,881,923,968,1013,1057,1103,1152,1201,1249,1299,1352,1405,1457

%N a(0)=0, a(1)=a(2)=1; thereafter, a(n+1) = n^2 - a(n-1).

%C 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.

%H Harvey P. Dale, <a href="/A187093/b187093.txt">Table of n, a(n) for n = 0..1000</a>

%H <a href="/index/Rec#order_05">Index entries for linear recurrences with constant coefficients</a>, signature (3,-4,4,-3,1).

%F a(n) = (n^2 - 1 + (-1)^floor(n/2) * A000034(n))/2.

%F G.f.: x*(-1+2*x+x^3-4*x^2) / ( (x^2+1)*(x-1)^3 ).

%F a(2^(n+1)) = A081654(n). - _Anton Zakharov_, Sep 13 2016

%p A000034 := proc(n) op(1+(n mod 2),[1,2]) ; end proc:

%p A187093 := proc(n) (n^2-1+(-1)^floor(n/2)*A000034(n))/2 ;end proc: # _R. J. Mathar_

%t LinearRecurrence[{3, -4, 4, -3, 1}, {0, 1, 1, 3, 8}, 60] (* _Jean-François Alcover_, Mar 30 2020 *)

%t 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 *)

%o (Python)

%o print(0, end=',') # a(-1)=0

%o prpr = prev = 1 # a(0)=a(1)=1

%o for n in range(2, 77):

%o print(prpr, end=',')

%o curr = n*n - prpr # a(n) = n^2 - a(n-2)

%o prpr = prev

%o prev = curr

%o # from _Alex Ratushnyak_, Aug 05 2012

%o (PARI) a(n) = (n^2-1+(-1)^(n\2)*(1 + (n % 2)))/2; \\ _Michel Marcus_, Sep 11 2016

%Y Cf. A194274, A081654.

%K nonn

%O 0,4

%A _Benjamin Coinsin_, Mar 04 2011

%E Edited by _N. J. A. Sloane_, Mar 09 2011

%E More terms from _Alex Ratushnyak_, Aug 05 2012