login
a(2^k) = k + 1 and a(2^k + i) = 1 + a(i) for k >= 0 and 0 < i < 2^k.
22

%I #99 Jan 12 2024 01:13:12

%S 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,

%T 3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,2,3,3,4,

%U 3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,3,4,4,5,4,5,5,6,4

%N a(2^k) = k + 1 and a(2^k + i) = 1 + a(i) for k >= 0 and 0 < i < 2^k.

%C Hamming weights of odd numbers. - _Friedjof Tellkamp_, Jan 11 2024

%H Michael Gilleland, <a href="/selfsimilar.html">Some Self-Similar Integer Sequences</a>

%F a(n) = A000120(n-1) + 1.

%F a(n) = log(A131136)/log(2). - _Stephen Crowley_, Aug 25 2008

%F a(n) = A007814(n) + A000120(n). - _Gary W. Adamson_, Jun 04 2009

%F a(n) = A000120(A086799(n)). - _Reinhard Zumkeller_, Jul 31 2010

%F a(n) = A000120(A047457(n)-1) = A000120(A047457(n)+1). - _Ilya Lopatin_, Mar 16 2014

%F a(n) = A000120(2n-1). - _Friedjof Tellkamp_, Jan 11 2024

%e k = 3: a(2^3) = a(8) = 4 = 3 + 1.

%e k = 3, i = 5: a(2^3 + 5) = a(13) = 3 = 1 + 2 = 1 + a(5).

%e From _Omar E. Pol_, Jun 12 2009: (Start)

%e Triangle begins:

%e 1;

%e 2,2;

%e 3,2,3,3;

%e 4,2,3,3,4,3,4,4;

%e 5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5;

%e 6,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6;

%e 7,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,3,4,4,5,...

%e (End)

%t Table[DigitCount[2 n - 1, 2, 1], {n, 1, 105}] (* _Friedjof Tellkamp_, Jan 11 2024 *)

%o (Python)

%o def a(n): return bin(n-1).count('1') + 1

%o print([a(n) for n in range(1, 106)]) # _Michael S. Branicky_, Dec 16 2021

%o (PARI) a(n) = hammingweight(n-1) + 1; \\ _Michel Marcus_, Nov 23 2022

%Y Cf. A000079, A000120, A007814, A086799, A047457, A131136.

%Y Cf. A330038 (partial sums).

%K nonn

%O 1,2

%A _Reinhard Zumkeller_, Aug 16 2001