login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A284013
a(n) = n - A002487(n).
6
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, 19, 25, 22, 26, 26, 31, 27, 29, 26, 32, 26, 31, 29, 37, 30, 34, 30, 39, 33, 39, 38, 46, 40, 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
OFFSET
0,5
LINKS
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
(Scheme) (define (A284013 n) (- n (A002487 n))) ;; Code for A002487 given under that entry.
(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