OFFSET
0,4
COMMENTS
The k-th bit in a(n) is one just if there are an odd number of pairs of distinct one bits i#j in n such that i+j=k. GF(2) polynomial ("XOR numbral") multiplication can be implemented as A048720(i,j) = A000695(i AND j) XOR a(i AND j) XOR a(i IOR j) XOR a(i AND NOT j) XOR a(NOT i AND j), analogously to ordinary multiplication (A003991) ij = tri(i+j)-tri(i)-tri(j) via triangular numbers (A000217).
REFERENCES
Posting by Richard C. Schroeppel to math-fun mailing list, Jun 26 2006.
LINKS
Rémy Sigrist, Table of n, a(n) for n = 0..8192
FORMULA
a(0)=0; a(n + 2^k) = a(n) XOR (n * 2^k), 0<=n<2^k.
EXAMPLE
a(15)=54 because 15=2^0+2^1+2^2+2^3, the four one-bits giving six distinct pairs 01 02 03 12 13 23, which sum to 1 2 3 3 4 5, of which 1 2 4 and 5 occur oddly, yielding 2^1+2^2+2^4+2^5=54.
PROG
(PARI) a(n) = { if (n==0, return (0), my (k=#binary(n)-1, m=n-2^k); return (bitxor(m*2^k, a(m)))) } \\ Rémy Sigrist, Feb 08 2020
CROSSREFS
KEYWORD
base,easy,nonn
AUTHOR
Marc LeBrun, Jun 28 2006
EXTENSIONS
Data corrected by Rémy Sigrist, Feb 08 2020
STATUS
approved