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.

User: William K. Grannis

William K. Grannis's wiki page.

William K. Grannis has authored 2 sequences.

A274009 1's distance from a number in its binary expansion.

Original entry on oeis.org

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

Author

William K. Grannis, Jun 06 2016

Keywords

Comments

To generate the value for n, write out n's decimal expansion. Then, write out 1's decimal expansion (0000000000....001). Compute how many times you need to change 0 to a 1 or a 1 to a 0 in order to switch from one number to the other.
The value for 2^x is always 2. The value for 2^x +1 is always 1. The value for 2^x -1 is always x-1 when x > 0. To get to 2^x, you need to drop the 1 at the beginning and add the 1 in the 2^x place value.
For 2^x + 1, you need to add the 1 in the 2^n place value, but you keep the 1 in the 1s place value. Thus you are only adding or getting rid of 1 digit.
For 2^x -1, it will have x digits, and all of them will be 1's. You already have 1 in the 1's place value, so there are n-1 digits left over.

Crossrefs

Cf. A000120.

Programs

  • Mathematica
    Table[If[OddQ@ n, # - 1, # + 1] &@ DigitCount[n, 2, 1], {n, 0, 120}] (* Michael De Vlieger, Jul 13 2016 *)
  • PARI
    a(n) = hammingweight(n) + (-1)^n; \\ Michel Marcus, Jul 14 2016

Formula

a(n) = A000120(n) + (-1)^n. - Michel Marcus, Jul 14 2016

Extensions

More terms from Michel Marcus, Jul 13 2016

A273149 a(n) = A053839(n)+1.

Original entry on oeis.org

1, 2, 3, 4, 2, 3, 4, 1, 3, 4, 1, 2, 4, 1, 2, 3, 2, 3, 4, 1, 3, 4, 1, 2, 4, 1, 2, 3, 1, 2, 3, 4, 3, 4, 1, 2, 4, 1, 2, 3, 1, 2, 3, 4, 2, 3, 4, 1, 4, 1, 2, 3, 1, 2, 3, 4, 2, 3, 4, 1, 3, 4, 1, 2, 2, 3, 4, 1, 3, 4, 1, 2, 4, 1, 2, 3, 1, 2, 3, 4, 3, 4, 1, 2, 4, 1, 2, 3, 1, 2, 3, 4, 2, 3, 4, 1, 4, 1, 2
Offset: 0

Author

William K. Grannis, May 16 2016

Keywords

Comments

A four-way fair share sequence. This is similar to the Thue-Morse Sequence. The Thue-Morse Sequence is the fairest way to split objects amongst two groups. If we call the groups A and B, most people split ABABABABABABABABABABABAB.......
This is unfair for B, because out of the best 2, A gets the best. Out of the second best 2, a gets the best. The Thue-Morse Sequence solves this:
ABBABAABBAABABBABAABABBAABBABAAB... The easiest way to generate the Thue-Morse Sequence is starting with a 1. Every 1 becomes 12. Every 2 becomes 21. Thus the sequence is obtained by recursion.
The present sequence is the same, but for splitting objects amongst 4 groups. Start with a 1. Every 1 becomes 1,2,3,4. Every 2 becomes 2,3,4,1. Every 3 becomes 3,4,1,2. Every 4 becomes 4,1,2,3.

Crossrefs