OFFSET
0,2
LINKS
Paolo Xausa, Table of n, a(n) for n = 0..10000
FORMULA
MAPLE
XOR := (n, k) -> Bits:-Xor(n, k):
a := n -> local k; add(XOR(k, n-k), k=0..n):
seq(a(n), n = 0..52);
MATHEMATICA
(* Using definition *)
Table[Sum[BitXor[n - k, k], {k, 0, n}], {n, 0, 100}]
(* Using recurrence -- faster *)
a[0] = 0; a[n_] := a[n] = If[OddQ[n], 4*a[(n-1)/2] + n + 1, 2*(a[n/2] + a[n/2-1])];
Table[a[n], {n, 0, 100}] (* Paolo Xausa, Oct 01 2024 *)
PROG
(PARI) a(n) = sum(k=0, n, bitxor(k, n-k)); \\ Michel Marcus, Sep 28 2024
CROSSREFS
KEYWORD
nonn
AUTHOR
Peter Luschny, Sep 27 2024
STATUS
approved