login
a(n) is the complement of the bit two places to the left of the least significant "1" in the binary expansion of n.
1

%I #22 Apr 08 2021 15:50:28

%S 1,1,1,1,1,0,1,0,1,1,0,1,1,0,0,0,1,1,1,1,0,0,1,0,1,1,0,1,0,0,0,0,1,1,

%T 1,1,1,0,1,0,0,1,0,1,1,0,0,0,1,1,1,1,0,0,1,0,0,1,0,1,0,0,0,0,1,1,1,1,

%U 1,0,1,0,1,1,0,1,1,0,0,0,0,1,1,1,0,0,1,0,1,1,0,1,0

%N a(n) is the complement of the bit two places to the left of the least significant "1" in the binary expansion of n.

%H Michael De Vlieger, <a href="/A342892/b342892.txt">Table of n, a(n) for n = 0..16384</a>

%e The bit to be complemented is in (parens).

%e n = 13 = 1(1)01_2, so a(13) = 0.

%e n = 12 = 1100_2 = (0)1100_2 so a(12) = complement of initial 0 = 1.

%p a342892 := proc(n) local p,s1,s2,i;

%p if n=0 then return(1); fi;

%p s1:=convert(n,base,2); s2:=nops(s1);

%p for i from 1 to s2 do if s1[i]=1 then p:=i; break; fi; od:

%p if p <= s2-2 then 1-s1[p+2]; else 1; fi; end;

%p [seq(a342892(i),i=0..120)];

%p # second Maple program:

%p a:= n-> 1-irem(iquo(n/2^padic[ordp](n, 2), 4), 2):

%p seq(a(n), n=0..120); # _Alois P. Heinz_, Apr 08 2021

%t {0}~Join~Array[If[#2 < 1, 1, #1[[#2]] /. {0 -> 1, 1 -> 0}] & @@ {#, Position[#, 1][[-1, 1]] - 2} &[IntegerDigits[#, 2]] &, 104] (* _Michael De Vlieger_, Apr 08 2021 *)

%o (Python)

%o def A342892(n):

%o s = bin(n)[2:]

%o m = len(s)

%o i = s[::-1].find('1')

%o return 1-int(s[m-i-3]) if m-i-3 >= 0 else 1 # _Chai Wah Wu_, Apr 08 2021

%Y If we change "two places" to "one place" we get A014577.

%K nonn

%O 0

%A _N. J. A. Sloane_, Apr 08 2021.