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.

A361838 a(n) is the number of 2s in the binary hereditary representation of 2n.

Original entry on oeis.org

1, 2, 3, 2, 3, 4, 5, 3, 4, 5, 6, 5, 6, 7, 8, 3, 4, 5, 6, 5, 6, 7, 8, 6, 7, 8, 9, 8, 9, 10, 11, 4, 5, 6, 7, 6, 7, 8, 9, 7, 8, 9, 10, 9, 10, 11, 12, 7, 8, 9, 10, 9, 10, 11, 12, 10, 11, 12, 13, 12, 13, 14, 15, 4, 5, 6, 7, 6, 7, 8, 9, 7, 8, 9, 10, 9, 10, 11, 12, 7
Offset: 1

Views

Author

Jodi Spitz, Mar 26 2023

Keywords

Comments

See comments on A266201 for the definition of hereditary representation.

Examples

			A table of n, the binary hereditary representation of 2n, and the number of 2s in the representation:
 n | hereditary rep. of 2n   | number of 2s
---+-------------------------+--------------
 1 | 2                       |      1
 2 | 2^2                     |      2
 3 | 2^2+2                   |      3
 4 | 2^(2+1)                 |      2
 5 | 2^(2+1)+2               |      3
 6 | 2^(2+1)+2^2             |      4
 7 | 2^(2+1)+2^2+2           |      5
 8 | 2^2^2                   |      3
 9 | 2^2^2+2                 |      4
10 | 2^2^2+2^2               |      5
11 | 2^2^2+2^2+2             |      6
12 | 2^2^2+2^(2+1)           |      5
13 | 2^2^2+2^(2+1)+2         |      6
14 | 2^2^2+2^(2+1)+2^2       |      7
15 | 2^2^2+2^(2+1)+2^2+2     |      8
16 | 2^(2^2+1)               |      3
17 | 2^(2^2+1)+2             |      4
18 | 2^(2^2+1)+2^2           |      5
19 | 2^(2^2+1)+2^2+2         |      6
20 | 2^(2^2+1)+2^(2+1)       |      5
21 | 2^(2^2+1)+2^(2+1)+2     |      6
22 | 2^(2^2+1)+2^(2+1)+2^2   |      7
23 | 2^(2^2+1)+2^(2+1)+2^2+2 |      8
24 | 2^(2^2+1)+2^2^2         |      6
25 | 2^(2^2+1)+2^2^2+2       |      7
26 | 2^(2^2+1)+2^2^2+2^2     |      8
27 | 2^(2^2+1)+2^2^2+2^2+2   |      9
28 | 2^(2^2+1)+2^2^2+2^(2+1) |      8
		

Crossrefs

Programs

  • PARI
    a(n)=if(n==0, 0, sum(k=0, logint(n,2), if(bittest(n,k), 1 + a((k+1)\2)))) \\ Andrew Howroyd, Apr 07 2023