OFFSET
1,4
LINKS
Kevin Ryde, Table of n, a(n) for n = 1..8192
Hsien-Kuei Hwang, Svante Janson, and Tsung-Hsi Tsai, Identities and periodic oscillations of divide-and-conquer recurrences splitting at half, arXiv:2210.10968 [cs.DS], 2022, pp. 49-50.
FORMULA
a(n) = (n+1+(2/3)*(4^e_4-1)+(-1)^e_2*(n-1-2*(4^e_4-1)))/2 where e_4=floor(log[4](n)) and e_2=floor(log[2](n))=floor(log[4](n^2)). - Antonio G. Astudillo (afg_astudillo(AT)hotmail.com), Feb 22 2003
a(n) = n - A079954(n). Let k=A000523(n), then a(n) = n-A000975(k) if k even, or a(n) = A000975(k) if k odd. - Kevin Ryde, Jul 13 2019
MATHEMATICA
Accumulate@ Flatten@ Table[1 - Mod[n, 2], {n, 0, 6}, {2^n}] (* Michael De Vlieger, Oct 29 2022 *)
PROG
(PARI) a(n) = my(k=logint(n, 2), p=(2<<k)\3); if(bittest(k, 0), p, n-p); /* Kevin Ryde, Jul 13 2019 */
(Python)
def A079947(n): return n-((1<<k)-2)//3 if (k:=n.bit_length())&1 else ((1<<k)-1)//3 # Chai Wah Wu, Jan 30 2023
CROSSREFS
KEYWORD
nonn
AUTHOR
N. J. A. Sloane, Feb 22 2003
STATUS
approved