OFFSET
0,4
LINKS
FORMULA
MATHEMATICA
Table[BitXor[Fold[BitXor, n, Quotient[n, 2^Range[BitLength@ n - 1]]], 2 n - DigitCount[2 n, 2, 1]], {n, 0, 84}] (* Michael De Vlieger, Mar 20 2017, after Jan Mangaldan at A006068 *)
PROG
(Scheme) (define (A283999 n) (A003987bi (A005187 n) (A006068 n))) ;; Where A003987bi implements bitwise-XOR (A003987).
(PARI) b(n) = if(n<1, 0, b(n\2) + n%2);
A(n) = 2*n - b(2*n);
a(n) = if(n<2, n, 2*a(floor(n/2)) + (n%2 + a(floor(n/2))%2)%2);
for(n=0, 110, print1(bitxor(A(n), a(n)), ", ")) \\ Indranil Ghosh, Mar 25 2017
(Python)
def A(n): return 2*n - bin(2*n)[2:].count("1")
def a(n): return n if n<2 else 2*a(n//2) + (n%2 + a(n//2)%2)%2
print([A(n)^a(n) for n in range(111)]) # Indranil Ghosh, Mar 25 2017
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Antti Karttunen, Mar 20 2017
STATUS
approved