login
Odd numbers whose binary representation contains an even number of 1's and at least one 0.
2

%I #58 Jan 13 2019 03:09:29

%S 5,9,17,23,27,29,33,39,43,45,51,53,57,65,71,75,77,83,85,89,95,99,101,

%T 105,111,113,119,123,125,129,135,139,141,147,149,153,159,163,165,169,

%U 175,177,183,187,189,195,197,201,207,209,215,219,221,225,231,235,237

%N Odd numbers whose binary representation contains an even number of 1's and at least one 0.

%H Lei Zhou, <a href="/A276194/b276194.txt">Table of n, a(n) for n = 1..10000</a>

%H <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>

%F a(2^n - floor(n/2)) = 4*2^n + 1, for all n >= 0. - _Gheorghe Coserea_, Oct 24 2016

%e Binary expansions of odd integers in decimal and binary forms are as follows:

%e 1 -> 1, no;

%e 3 -> 11, no;

%e 5 -> 101, yes, so a(1)=5;

%e 7 -> 111, no;

%e 9 -> 1001, yes so a(2)=9;

%e 11 -> 1011, no;

%e 13 -> 1101, no;

%e 15 -> 1111, no;

%e 17 -> 10001, yes so a(3)=17.

%t BNDigits[m_Integer] :=

%t Module[{n = m, d, t = {}},

%t While[n > 0, d = Mod[n, 2]; PrependTo[t, d]; n = (n - d)/2]; t];

%t c = 1;

%t Table[While[c = c + 2; d = BNDigits[c]; ld = Length[d];

%t c1 = Total[d]; ! (EvenQ[c1] && (c1 < ld))]; c, {n, 1, 57}]

%o (PARI) isok(n) = my(b=binary(n)); (n % 2) && (vecmin(b)==0) && !(vecsum(b) % 2); \\ _Michel Marcus_, Oct 21 2016

%o (PARI)

%o seq(N) = {

%o my(bag = List(), cnt = 0, n = 1);

%o while(cnt < N,

%o if (hammingweight(n)%2 == 0 && hammingweight(n+1) > 1,

%o listput(bag, n); cnt++);

%o n += 2);

%o return(Vec(bag));

%o };

%o seq(57) \\ _Gheorghe Coserea_, Oct 25 2016

%Y Cf. A005408.

%Y Intersection of A129771 and A062289.

%K nonn,base

%O 1,1

%A _Lei Zhou_, Oct 20 2016