|
|
A037888
|
|
a(n) = (1/2)*Sum_{i} |d(i) - e(i)| where Sum_{i} d(i)*2^i is the base-2 representation of n and e(i) are digits d(i) in reverse order.
|
|
13
|
|
|
0, 1, 0, 1, 0, 1, 0, 1, 0, 2, 1, 2, 1, 1, 0, 1, 0, 2, 1, 1, 0, 2, 1, 2, 1, 1, 0, 2, 1, 1, 0, 1, 0, 2, 1, 2, 1, 3, 2, 2, 1, 3, 2, 1, 0, 2, 1, 2, 1, 1, 0, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0, 1, 0, 2, 1, 2, 1, 3, 2, 1, 0, 2, 1, 2, 1, 3, 2, 2, 1, 3, 2, 1, 0, 2, 1, 2, 1, 3
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,10
|
|
COMMENTS
|
a(n) = least number of digits for which the change 0->1 in (binary n) yields a palindrome.
|
|
LINKS
|
|
|
MAPLE
|
a:= proc(n) local r, ad: r:= proc(s) options operator, arrow: [seq(s[nops(s)-j+1], j = 1 .. nops(s))] end proc: ad := proc(s) local i, j: j := 0: for i to nops(s) do if 0 < abs((s-r(s))[i]) then j := j+1 else end if end do: (1/2)*j end proc: ad(convert(n, base, 2)) end proc: seq(a(n), n = 1 .. 90); # Emeric Deutsch, Aug 20 2016
|
|
MATHEMATICA
|
a[n_] := (bits = IntegerDigits[n, 2]; Total[Abs[bits - Reverse[bits]]]/2); Table[a[n], {n, 1, 90}] (* Jean-François Alcover, Jan 16 2013 *)
|
|
PROG
|
(PARI)
for(n = 1, 90,
v = binary(n); s = 0; j = #v;
for(k=1, #v, s+=abs(v[k]-v[j]); j--);
s/=2;
print1(s, ", ")
)
(Haskell)
a037888 n = div (sum $ map abs $ zipWith (-) bs $ reverse bs) 2
where bs = a030308_row n
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn,base,nice
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|