login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

a(n) = a(n-2) - (a(n-1) - a(n-2)) if (n mod 2) = 0, otherwise a(n) = a(n-1) - (a(n-3) - a(n-4)), with a(0) = 0, a(1) = 1, a(2) = -1, a(3) = 2.
4

%I #32 Nov 28 2021 04:43:37

%S 0,1,-1,2,-4,-2,-6,0,-12,-8,-16,-4,-28,-20,-36,-12,-60,-44,-76,-28,

%T -124,-92,-156,-60,-252,-188,-316,-124,-508,-380,-636,-252,-1020,-764,

%U -1276,-508,-2044,-1532,-2556,-1020,-4092,-3068,-5116,-2044,-8188,-6140,-10236,-4092,-16380,-12284,-20476

%N a(n) = a(n-2) - (a(n-1) - a(n-2)) if (n mod 2) = 0, otherwise a(n) = a(n-1) - (a(n-3) - a(n-4)), with a(0) = 0, a(1) = 1, a(2) = -1, a(3) = 2.

%H G. C. Greubel, <a href="/A135690/b135690.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 (1,0,0,2,-2).

%F G.f.: x*(1-2*x)*(1+3*x^2)/((1-x)*(1-2*x^4)). - _Colin Barker_, Jan 26 2013

%F a(n) = 4 - C*2^floor(n/4), where C = 4,3,5,2 according as n mod 4 = 0,1,2,3 respectively. - _Kevin Ryde_, Nov 26 2021

%t a[0] = 0; a[1] = 1; a[2] = -1; a[3] = 2; a[n_]:= a[n]= If[Mod[n, 2]==0, a[n-2] - (a[n-1] -a[n-2]), a[n-1] -(a[n-3] -a[n-4])]; Table[a[n], {n, 0, 60}]

%o (Sage)

%o @CachedFunction

%o def A135690(n):

%o if (n<2): return n

%o elif (n<4): return (-1)^(n+1)*(n-1)

%o elif (n%2==0): return A135690(n-2) - (A135690(n-1) - A135690(n-2))

%o else: return A135690(n-1) - (A135690(n-3) - A135690(n-4))

%o [A135690(n) for n in (0..60)] # _G. C. Greubel_, Nov 24 2021

%o (PARI) a(n) = 4 - [4,3,5,2][n%4+1] << (n>>2); \\ _Kevin Ryde_, Nov 26 2021

%Y Cf. A135689, A135692.

%K easy,sign,less

%O 0,4

%A _Roger L. Bagula_, Feb 19 2008

%E Edited by _G. C. Greubel_ and _Kevin Ryde_, Nov 24 2021