OFFSET
0,2
COMMENTS
All terms are even.
LINKS
David A. Corneth, Table of n, a(n) for n = 0..9999
Joerg Arndt, Matters Computational (The Fxtbook)
FORMULA
a(A112627(n)) = 2*n and A112627(n) is the first position where 2*n occurs in this sequence. - David A. Corneth, Sep 19 2019
EXAMPLE
00101_2 * 100_2 = 10100_2: 2 bits changed, so a(5) = 2.
MAPLE
a:= n-> add(i, i=Bits[Split](Bits[Xor](n*4, n))):
seq(a(n), n=0..120); # Alois P. Heinz, Aug 23 2019
MATHEMATICA
a[n_] := Total@ IntegerDigits[BitXor[n, 4 n], 2]; Array[a, 88, 0] (* Giovanni Resta, Sep 19 2019 *)
PROG
(PARI) A309709(n) = hammingweight(bitxor(n, n<<2)); \\ Antti Karttunen, Aug 22 2019
(Python)
def A309709(n):
s = ""
while n > 0:
s, n = str(n%2)+s, n//2
s, s4, i, j = "00"+s, s+"00", 0, 0
while i < len(s):
if s[i] != s4[i]:
j = j+1
i = i+1
return j # A.H.M. Smeets, Aug 23 2019
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
Ali Sada, Aug 14 2019
STATUS
approved