login
A342892
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
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, 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, 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
OFFSET
0
LINKS
EXAMPLE
The bit to be complemented is in (parens).
n = 13 = 1(1)01_2, so a(13) = 0.
n = 12 = 1100_2 = (0)1100_2 so a(12) = complement of initial 0 = 1.
MAPLE
a342892 := proc(n) local p, s1, s2, i;
if n=0 then return(1); fi;
s1:=convert(n, base, 2); s2:=nops(s1);
for i from 1 to s2 do if s1[i]=1 then p:=i; break; fi; od:
if p <= s2-2 then 1-s1[p+2]; else 1; fi; end;
[seq(a342892(i), i=0..120)];
# second Maple program:
a:= n-> 1-irem(iquo(n/2^padic[ordp](n, 2), 4), 2):
seq(a(n), n=0..120); # Alois P. Heinz, Apr 08 2021
MATHEMATICA
{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 *)
PROG
(Python)
def A342892(n):
s = bin(n)[2:]
m = len(s)
i = s[::-1].find('1')
return 1-int(s[m-i-3]) if m-i-3 >= 0 else 1 # Chai Wah Wu, Apr 08 2021
CROSSREFS
If we change "two places" to "one place" we get A014577.
Sequence in context: A114592 A344864 A140653 * A071036 A071038 A131522
KEYWORD
nonn
AUTHOR
N. J. A. Sloane, Apr 08 2021.
STATUS
approved