A144078 a(n) = the number of digits in the binary representation of n that differ from the corresponding digit in the binary reversal of n. (I.e., a(n) = number of 1's in n XOR A030101(n).)
0, 2, 0, 2, 0, 2, 0, 2, 0, 4, 2, 4, 2, 2, 0, 2, 0, 4, 2, 2, 0, 4, 2, 4, 2, 2, 0, 4, 2, 2, 0, 2, 0, 4, 2, 4, 2, 6, 4, 4, 2, 6, 4, 2, 0, 4, 2, 4, 2, 2, 0, 6, 4, 4, 2, 6, 4, 4, 2, 4, 2, 2, 0, 2, 0, 4, 2, 4, 2, 6, 4, 2, 0, 4, 2, 4, 2, 6, 4, 4, 2, 6, 4, 2, 0, 4, 2, 4, 2, 6, 4, 2, 0, 4, 2, 4, 2, 2, 0, 6, 4, 4, 2, 4, 2
Offset: 1
Examples
20 in binary is 10100. Compare this with its digit reversal, 00101. XOR each pair of corresponding digits: 1 XOR 0 = 1, 0 XOR 0 = 0, 1 XOR 1 = 0, 0 XOR 0 = 0, 0 XOR 1 = 1. There are two bit pairs that differ, so a(20) = 2.
Links
- Harvey P. Dale, Table of n, a(n) for n = 1..1000
Programs
-
Maple
A144078 := proc(n) local a,dgs,i; a := 0 ; dgs := convert(n,base,2) ; for i from 1 to nops(dgs) do if op(i,dgs)+op(-i,dgs) = 1 then a := a+1 ; fi; od; RETURN(a) ; end: for n from 1 to 240 do printf("%d,",A144078(n)) ; od: # R. J. Mathar, Sep 14 2008
-
Mathematica
brd[n_]:=Module[{idn2=IntegerDigits[n,2]},Count[Transpose[{idn2, Reverse[ idn2]}], ?(#[[1]]!=#[[2]]&)]]; Array[brd,110] (* _Harvey P. Dale, May 09 2016 *)
-
PARI
a(n) = hammingweight(bitxor(n, fromdigits(Vecrev(binary(n)),2))) \\ Rémy Sigrist, Oct 07 2018
Formula
Extensions
More terms from R. J. Mathar, Sep 14 2008
Comments