Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.
%I #22 May 19 2023 01:45:48
%S 0,0,1,1,3,2,4,4,7,5,7,6,10,8,11,11,15,12,14,12,17,13,17,16,22,18,21,
%T 19,25,22,26,26,31,27,29,26,32,26,31,29,37,30,34,30,39,33,39,38,46,40,
%U 43,39,47,40,46,44,53,47,51,48,56,52,57,57,63,58,60,56,63,55,61,58,68,58,63,57,69,60,68,66,77,67,71,64,76,64
%N a(n) = n - A002487(n).
%H Antti Karttunen, <a href="/A284013/b284013.txt">Table of n, a(n) for n = 0..8192</a>
%F a(n) = n - A002487(n).
%t 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 *)
%o (Scheme) (define (A284013 n) (- n (A002487 n))) ;; Code for A002487 given under that entry.
%o (PARI)
%o A(n) = if(n<2, n, if(n%2, A(n\2) + A((n + 1)/2), A(n/2)));
%o for(n=0, 151, print1(n - A(n),", ")) \\ _Indranil Ghosh_, Mar 23 2017
%o (Python)
%o 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))
%o print([n - a(n) for n in range(101)]) # _Indranil Ghosh_, Mar 23 2017
%o (Python)
%o from functools import reduce
%o 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
%Y Cf. A002487, A265397, A283474, A284007.
%K nonn
%O 0,5
%A _Antti Karttunen_, Mar 23 2017