login
A174232
a(n) = a(n-1) - (-1)^n*n if (A004001(n) mod 3) = 1, otherwise a(n-1) + (-1)^n*n.
2
1, 0, -2, -5, -1, -6, -12, -5, -13, -22, -12, -1, -13, -26, -12, -27, -11, -28, -46, -65, -45, -66, -88, -111, -87, -112, -86, -113, -141, -112, -142, -111, -143, -176, -142, -107, -71, -108, -70, -31, 9, -32, 10, 53, 97, 52, 98, 51, 99, 148, 198, 147, 199, 146
OFFSET
0,3
LINKS
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
Sequence in context: A079614 A238387 A084245 * A065224 A325137 A321966
KEYWORD
sign
AUTHOR
Roger L. Bagula, Mar 13 2010
EXTENSIONS
Edited by G. C. Greubel, Nov 24 2021
STATUS
approved