A261283 a(n) = bitwise XOR of all the bit numbers for the bits that are set in n, using number 1 for the LSB.
0, 1, 2, 3, 3, 2, 1, 0, 4, 5, 6, 7, 7, 6, 5, 4, 5, 4, 7, 6, 6, 7, 4, 5, 1, 0, 3, 2, 2, 3, 0, 1, 6, 7, 4, 5, 5, 4, 7, 6, 2, 3, 0, 1, 1, 0, 3, 2, 3, 2, 1, 0, 0, 1, 2, 3, 7, 6, 5, 4, 4, 5, 6, 7, 7, 6, 5, 4, 4, 5, 6, 7, 3, 2, 1, 0, 0, 1, 2, 3, 2, 3, 0, 1, 1, 0
Offset: 0
Examples
a(7) = a(4+2+1) = a(2^2+2^1+2^0) = (2+1) XOR (1+1) XOR (0+1) = 3 XOR 3 = 0. a(12) = a(8+4) = a(2^3+2^2) = (3+1) XOR (2+1) = 4+3 = 7.
Links
- Philippe Beaudoin, Table of n, a(n) for n = 0..8190
- Oliver Nash, Yet another prisoner puzzle, coins on a chessboard problem.
- Tilman Piesk, Illustration of the first 128 terms
Programs
-
Mathematica
A261283[n_] := If[n == 0, 0, BitXor @@ PositionIndex[Reverse[IntegerDigits[n, 2]]][1]]; Array[A261283, 100, 0] (* Paolo Xausa, May 29 2024 *)
-
PARI
A261283(n,b=bittest(n,0))={for(i=1,#binary(n),bittest(n,i)&&b=bitxor(b,i+1));b}
Comments