[go: up one dir, main page]

login
A135692
a(n) = a(n-2) - 2*( a(floor(n/2)) - a(abs(floor(n/2) - 1)) ) if (n mod 2) = 0, otherwise a(n-1) - 2*( a(abs(floor(n/2) - 2)) - a(abs(floor(n/2) - 3)) ), with a(0) = 0, a(1) = 1, a(2) = -2, a(3) = -4.
4
0, 1, -2, -4, 4, 6, 8, 6, -8, -2, -12, -8, -16, -32, -12, -16, 16, 12, 4, 8, 24, 52, 16, 4, 32, 52, 64, 56, 24, 40, 32, 64, -32, -72, -24, -16, -8, -72, -16, -8, -48, -32, -104, -112, -32, -64, -8, -64, -64, 8, -104, -80, -128, -184, -112, -152, -48, -72, -80, -64, -64, 0, -128, -160, 64, 80, 144, 80, 48, 240, 32, 112, 16, -80
OFFSET
0,3
LINKS
FORMULA
a(n) = a(n-2) - 2*( a(floor(n/2)) - a(abs(floor(n/2) - 1)) ) if (n mod 2) = 0, otherwise a(n-1) - 2*( a(abs(floor(n/2) - 2)) - a(abs(floor(n/2) - 3)) ), with a(0) = 0, a(1) = 1, a(2) = -2, a(3) = -4.
MATHEMATICA
a[n_]:= a[n]= If[n<2, n, If[n<4, -2^(n-1), If[Mod[n, 2]==0, a[n-2] - 2*( a[Floor[n/2]] - a[Abs[Floor[n/2] -1]]), a[n-1] - 2*(a[Abs[Floor[n/2] -2]] - a[Abs[Floor[n/2] -3]]) ]]];
Table[a[n], {n, 0, 80}]
PROG
(Sage)
@CachedFunction
def A135692(n):
if (n<2): return n
elif (n<4): return -2^(n-1)
elif (n%2==0): return A135692(n-2) - 2*(A135692(n//2) - A135692(abs(n//2 -1)))
else: return A135692(n-1) - 2*(A135692(abs(n//2 -2)) - A135692(abs(n//2 -3)))
[A135692(n) for n in (0..80)] # G. C. Greubel, Nov 24 2021
(PARI) See links.
CROSSREFS
Sequence in context: A288573 A288574 A376638 * A089003 A132118 A221952
KEYWORD
sign,easy
AUTHOR
Roger L. Bagula, Feb 21 2008
EXTENSIONS
Edited by G. C. Greubel, Nov 24 2021
STATUS
approved