OFFSET
0,5
LINKS
Antti Karttunen, Table of n, a(n) for n = 0..8192
FORMULA
a(n) = n - A002487(n).
MATHEMATICA
a[n_] :=If[n<2, n, If[ EvenQ[n], a[n/2], a[(n - 1)/2] + a[(n + 1)/2]]]; Table[n - a[n], {n , 0, 100}] (* Indranil Ghosh, Mar 23 2017 *)
PROG
(PARI)
A(n) = if(n<2, n, if(n%2, A(n\2) + A((n + 1)/2), A(n/2)));
for(n=0, 151, print1(n - A(n), ", ")) \\ Indranil Ghosh, Mar 23 2017
(Python)
def a(n): return n if n<2 else (a(n//2) if n%2==0 else a((n - 1)//2) + a((n + 1)//2))
print([n - a(n) for n in range(101)]) # Indranil Ghosh, Mar 23 2017
(Python)
from functools import reduce
def A284013(n): return n-sum(reduce(lambda x, y:(x[0], x[0]+x[1]) if int(y) else (x[0]+x[1], x[1]), bin(n)[-1:2:-1], (1, 0))) if n else 0 # Chai Wah Wu, May 18 2023
CROSSREFS
KEYWORD
nonn
AUTHOR
Antti Karttunen, Mar 23 2017
STATUS
approved