login
A332064
a(1) = 1, a(n + 1) = a(n) -(-1)^a(n) Sum_{k = 1..n} floor(log_2(a(k)) + 1): depending on parity of a(n), add or subtract the total number of bits of (absolute values of) the terms so far.
1
1, 2, -1, 3, 9, 19, 34, 13, 38, 7, 41, 81, 128, 73, 135, 205, 283, 370, 274, 169, 282, 160, 30, -105, 37, 185, 341, 506, 332, 149, 340, 140, -68, -283, -59, 171, 409, 656, 399, 665, 941, 1227, 1524, 1216, 897, 1226, 886, 536, 176, -192
OFFSET
1,2
COMMENTS
If a zero term were to arise, we would consider it to have 1 bit.
EXAMPLE
After a(1) = 1, since it is odd, we add the total number of bits so far, to get a(2) = 1 + 1 = 2.
After a(2) = 2, since it is even, we subtract the total number of (not necessarily nonzero) bits so far (#"1" = 1, #"10" = 2), to get a(3) = 2 - 3 = -1.
Since a(3) = -1 is odd, we add #"1" = 1, #"10" = 2 and #"1" = 1, to get a(4) = -1 + 4 = 3.
PROG
(PARI) ({A332064_vec(N, a=1, s=-a)=vector(N, n, a-=(-1)^a*s+=exponent(a+!a)+1)})(50)
CROSSREFS
Cf. A000120.
Cf. A332063 for a variant where the number of bits is always added, ignoring the parity of a(n).
Sequence in context: A126009 A301282 A246063 * A229417 A337890 A337888
KEYWORD
sign
AUTHOR
M. F. Hasler, Feb 27 2020
STATUS
approved