login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A261283 a(n) = bitwise XOR of all the bit numbers for the bits that are set in n, using number 1 for the LSB. 5

%I #18 Feb 08 2021 02:58:24

%S 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,

%T 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,

%U 4,5,6,7,3,2,1,0,0,1,2,3,2,3,0,1,1,0

%N a(n) = bitwise XOR of all the bit numbers for the bits that are set in n, using number 1 for the LSB.

%C If the least significant bit is numbered 0, then a(2n) = a(2n+1) if one uses the "natural" definition reading "...set in n": see A253315 for that version. To avoid the duplication, we chose here to start numbering the bits with 1 for the LSB; equivalently, we can start numbering the bits with 0 but use the definition "...bits set in 2n". In any case, a(n) = A253315(2n) = A253315(2n+1).

%C Since the XOR operation is associative, one can define XOR of an arbitrary number of terms in a recursive way, there is no ambiguity about the order in which the operations are performed.

%H Philippe Beaudoin, <a href="/A261283/b261283.txt">Table of n, a(n) for n = 0..8190</a>

%H O. Nash, <a href="http://ocfnash.wordpress.com/2009/10/31/yet-another-prisoner-puzzle/">Yet another prisoner puzzle</a>, coins on a chessboard problem.

%e 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.

%e a(12) = a(8+4) = a(2^3+2^2) = (3+1) XOR (2+1) = 4+3 = 7.

%o (PARI) A261283(n,b=bittest(n,0))={for(i=1,#binary(n),bittest(n,i)&&b=bitxor(b,i+1));b}

%Y Cf. A075926 (indices of 0's).

%K nonn,base,easy

%O 0,3

%A _M. F. Hasler_, Aug 14 2015, following the original version A253315 by _Philippe Beaudoin_, Dec 30 2014

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified March 29 04:59 EDT 2024. Contains 371264 sequences. (Running on oeis4.)