login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

Numbers n whose digital sum equals the number of binary digits in its binary expansion.
5

%I #18 May 30 2021 12:03:46

%S 1,2,13,23,33,42,51,60,70,106,115,124,134,143,152,161,170,206,215,224,

%T 233,242,251,261,270,306,315,324,333,342,351,360,405,414,423,432,441,

%U 450,504,514,523,532,541,550,604,613,622,631,640,703,712,721,730,802,811,820

%N Numbers n whose digital sum equals the number of binary digits in its binary expansion.

%H Andreas Boe, <a href="/A243615/b243615.txt">Table of n, a(n) for n = 1..10000</a>

%e 134 -> 1+3+4=8 134=10000110 -> Eight bits.

%t Select[Range[10^3], Total@ IntegerDigits@ # == 1 + Floor@ Log2@ # &] (* _Michael De Vlieger_, Nov 05 2018 *)

%t Select[Range[1000],Total[IntegerDigits[#]]==IntegerLength[#,2]&] (* _Harvey P. Dale_, May 30 2021 *)

%o (PARI) isok(n) = sumdigits(n) == #binary(n); \\ _Michel Marcus_, Jun 08 2014

%Y Cf. A000120, A007953.

%K nonn,base

%O 1,2

%A _Andreas Boe_, Jun 07 2014