OFFSET
0,3
LINKS
G. C. Greubel, Table of n, a(n) for n = 0..1000
FORMULA
a(n) = a(n-1) - (-1)^n*n if (A004001(n) mod 3) = 1, otherwise a(n-1) + (-1)^n*n, with a(0) = 1 and a(1) = 0.
MATHEMATICA
HC[n_]:= HC[n]= If[n<3, Fibonacci[n], HC[HC[n-1]] +HC[n -HC[n-1]]]; (*A004001*)
a[n_]:= a[n]= If[n<2, 1-n, If[Mod[HC[n], 3]==1, a[n-1] -(-1)^n*n, a[n-1] + (-1)^n*n]];
Table[a[n], {n, 0, 80}]
PROG
(Sage)
@CachedFunction
def HC(n): # HC = A004001
if (n<3): return fibonacci(n)
else: return HC(HC(n-1)) +HC(n -HC(n-1))
def A174232(n):
if (n<2): return 1-n
elif (HC(n)%3==1): return A174232(n-1) - (-1)^n*n
else: return A174232(n-1) + (-1)^n*n
[A174232(n) for n in (0..80)] # G. C. Greubel, Nov 24 2021
CROSSREFS
KEYWORD
sign
AUTHOR
Roger L. Bagula, Mar 13 2010
EXTENSIONS
Edited by G. C. Greubel, Nov 24 2021
STATUS
approved