cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A384956 Binary XOR of number of 1-bits in the binary representation of n and number of 0-bits in the binary representation of n, a(0) = 1.

Original entry on oeis.org

1, 1, 0, 2, 3, 3, 3, 3, 2, 0, 0, 2, 0, 2, 2, 4, 5, 1, 1, 1, 1, 1, 1, 5, 1, 1, 1, 5, 1, 5, 5, 5, 4, 6, 6, 0, 6, 0, 0, 6, 6, 0, 0, 6, 0, 6, 6, 4, 6, 0, 0, 6, 0, 6, 6, 4, 0, 6, 6, 4, 6, 4, 4, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
Offset: 0

Views

Author

Keywords

Comments

n=0 is taken to be a single 0 bit, and all other n are taken without leading 0 bits.
When the length of the binary representation of n is 2^k-1, then a(n) is 2^k-1.

Examples

			179 (10110011_2) has 5 (101_2) 1-bits and 3 (011_2) 0-bits. 101_2 XOR 011_2 = 110_2 = 6. a(179) = 6.
		

Crossrefs

Programs

  • Mathematica
    a[n_] := BitXor @@ DigitCount[n, 2]; Array[a, 100, 0] (* Amiram Eldar, Jun 13 2025 *)
  • Python
    def A384956(n):
        if n == 0 : return 1
        return (n.bit_length() - (Ham:=n.bit_count())) ^ Ham # Karl-Heinz Hofmann, Jun 14 2025

Formula

a(n) = A000120(n) XOR A023416(n).