The OEIS mourns the passing of Jim Simons and is grateful to the Simons Foundation for its support of research in many branches of science, including the OEIS.
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!)
A213064 Bitwise AND of 2n with the one's-complement of n. 4
0, 2, 4, 4, 8, 10, 8, 8, 16, 18, 20, 20, 16, 18, 16, 16, 32, 34, 36, 36, 40, 42, 40, 40, 32, 34, 36, 36, 32, 34, 32, 32, 64, 66, 68, 68, 72, 74, 72, 72, 80, 82, 84, 84, 80, 82, 80, 80, 64, 66, 68, 68, 72, 74, 72, 72, 64, 66, 68, 68, 64, 66, 64, 64, 128, 130, 132 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,2
COMMENTS
In two's-complement binary arithmetic, -n is ~(n - 1). As such, this could be written instead as a(n) = 2n AND -(n + 1). Further, because the least significant bits are never matched both of the operands to the AND, the negative form of n can be used rather than the one's-complement, i.e. a(n) = 2n AND -n.
a(n) has a 1-bit immediately above each run of 1's in n, and everywhere else 0's. Or equivalently, each 01 bit pair in n becomes 10 in a(n) and everywhere else 0's. The most significant 1-bit of n has a 0 above it for this purpose, so is an 01 bit pair. - Kevin Ryde, Jun 04 2020
LINKS
FORMULA
a(n) = 2n AND ~n
a(n) = 2*A292272(n). - Kevin Ryde, Jun 04 2020
EXAMPLE
For n = 31, 2n is 62, which in binary is 111110, as multiplication by two is the same as shifting the bits of 31 (11111) to the left by one. As the number is one less than a power of two, all of its least significant bits are set. Before the shift, the most significant bit has a value of 16. After the shift, the most significant bit has a value of 32.
The ~n has all bits set but the five least significant, the highest bit set being the power of two above n: .....111111111100000. When these two values are ANDed together, only the 6th bit, that with the value of 32, is common to them, and the result is 32.
From Kevin Ryde, Jun 04 2020: (Start)
n = 1831 = binary 11100100111
a(n) = 2120 = binary 100001001000 1-bit above each run
(End)
MATHEMATICA
Table[BitAND[2n, -n], {n, 0, 59}] (* Alonso del Arte, Jun 04 2012 *)
PROG
(C) int a(int n) { return ((n + n) & ~n); }
(R, with bitops) bitAnd(2 * n, bitFlip(n))
(PARI) a(n) = bitnegimply(n<<1, n); \\ Kevin Ryde, Jun 04 2020
(Python)
def A213064(n): return n<<1&~n # Chai Wah Wu, Jun 29 2022
CROSSREFS
Cf. A048724 (with XOR).
Sequence in context: A181212 A233394 A029599 * A076466 A073117 A342695
KEYWORD
nonn,base,easy
AUTHOR
Juli Mallett, Jun 04 2012
STATUS
approved

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 May 17 19:53 EDT 2024. Contains 372607 sequences. (Running on oeis4.)