OFFSET
0,3
LINKS
G. C. Greubel, Table of n, a(n) for n = 0..1000
FORMULA
a(n) = a(n-2) - (a(floor(n/2)) - 2*a(abs(floor(n/2) -1)) + a(abs(floor(n/2) -2)) ) if (n mod 2) = 0, otherwise a(n-1) - (a(abs(floor(n/2) - 2)) - 2*a(abs(floor(n/2) - 3)) + a(abs(floor(n/2) - 4)).
a(2*n) = a(2*n-2) - (a(n) - 2*a(n-1) + a(n-2)), for n > 2.
a(2*n+1) = a(2*n) - (a(n-2) - 2*a(n-3) + a(n-4)), for n > 3.
MATHEMATICA
a[0]:=0; a[1]:=1; a[2]:=3; a[3]:=-1; a[4]:=-2; a[5]:=-3; a[6]:=4; a[7]:=2;
a[n_]:= a[n]= If[Mod[n, 2]==0, a[n-2] -a[n/2] +2*a[n/2 -1] -a[n/2 -2], a[n-1] -a[(n-1)/2 -2] +2*a[(n-1)/2 -3] -a[(n-1)/2 -4]];
Table[a[n], {n, 0, 100}]
PROG
(Sage)
@CachedFunction
def a(n): # A135564
if (n<8): return [0, 1, 3, -1, -2, -3, 4, 2][n]
elif ((n%2)==0): return a(n-2) - a(n/2) + 2*a(n/2 - 1) - a(n/2 -2)
else: return a(n-1) - a((n-1)/2 - 2) + 2*a((n-1)/2 - 3) - a((n-1)/2 -4)
[a(n) for n in (0..100)] # G. C. Greubel, Nov 26 2021
CROSSREFS
KEYWORD
sign,easy,less
AUTHOR
Roger L. Bagula, Feb 23 2008
EXTENSIONS
Edited by G. C. Greubel, Nov 28 2021
STATUS
approved