login

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

Numbers with exactly 2 2's in their base 4 expansion.
2

%I #20 Sep 14 2023 08:10:55

%S 10,26,34,38,40,41,43,46,58,74,90,98,102,104,105,107,110,122,130,134,

%T 136,137,139,142,146,150,152,153,155,158,160,161,163,164,165,167,172,

%U 173,175,178,182,184,185,187,190,202,218,226,230,232,233,235,238,250,266

%N Numbers with exactly 2 2's in their base 4 expansion.

%H Seiichi Manyama, <a href="/A023715/b023715.txt">Table of n, a(n) for n = 1..10000</a>

%p q:= n-> numboccur(convert(n, base, 4), 2)=2:

%p select(q, [$1..350])[]; # _Alois P. Heinz_, Oct 26 2022

%t Select[ Range[ 240 ], (Count[ IntegerDigits[ #, 4 ], 2 ]==2)& ]

%o (Python)

%o def ok(n):

%o mask, c = 3, 0

%o for i in range(n.bit_length() >> 1):

%o if (mask&n) >> (i << 1) == 2: c += 1

%o mask <<= 2

%o return c == 2

%o print([k for k in range(227) if ok(k)]) # _Michael S. Branicky_, Oct 26 2022

%K nonn,base,easy

%O 1,1

%A _Olivier GĂ©rard_