login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
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

%I #30 Sep 03 2023 00:03:49

%S 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,

%T 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,

%U 1,3,2,1,0,2,1,2,1,3,2,2,1,3,2,1,0,2,1,2,1,3

%N 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.

%C a(n) = least number of digits for which the change 0->1 in (binary n) yields a palindrome.

%C a(n) = Sum_{k=0..A070939(n)/2-1} abs(A030308(n, k) - A030308(n, A070939(n)-k)). - _Reinhard Zumkeller_, Apr 09 2013

%C a(n) = Sum_{k=0..A070939(n)/2-1} ((A030308(n, k) + A030308(n, A070939(n)-k)) mod 2). - _Reinhard Zumkeller_, Sep 18 2013

%H Reinhard Zumkeller, <a href="/A037888/b037888.txt">Table of n, a(n) for n = 1..10000</a>

%p 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

%t 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 *)

%o (PARI)

%o for(n = 1, 90,

%o v = binary(n); s = 0; j = #v;

%o for(k=1,#v, s+=abs(v[k]-v[j]); j--);

%o s/=2;

%o print1(s,", ")

%o )

%o \\ _Washington Bomfim_, Jan 13 2011

%o (Haskell)

%o a037888 n = div (sum $ map abs $ zipWith (-) bs $ reverse bs) 2

%o where bs = a030308_row n

%o -- _Reinhard Zumkeller_, Apr 09 2013

%Y Cf. A064834.

%K nonn,base,nice

%O 1,10

%A _Clark Kimberling_

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 23 12:44 EDT 2024. Contains 371913 sequences. (Running on oeis4.)