A361838 a(n) is the number of 2s in the binary hereditary representation of 2n.
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
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
Links
- Antti Karttunen, Table of n, a(n) for n = 1..65537
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
Comments