cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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.

Original entry on oeis.org

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
Offset: 1

Views

Author

Keywords

Comments

a(n) = least number of digits for which the change 0->1 in (binary n) yields a palindrome.
a(n) = Sum_{k=0..A070939(n)/2-1} abs(A030308(n, k) - A030308(n, A070939(n)-k)). - Reinhard Zumkeller, Apr 09 2013
a(n) = Sum_{k=0..A070939(n)/2-1} ((A030308(n, k) + A030308(n, A070939(n)-k)) mod 2). - Reinhard Zumkeller, Sep 18 2013

Crossrefs

Cf. A064834.

Programs

  • Haskell
    a037888 n = div (sum $ map abs $ zipWith (-) bs $ reverse bs) 2
       where bs = a030308_row n
    -- Reinhard Zumkeller, Apr 09 2013
  • 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 *)
  • 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,", ")
    )
    \\ Washington Bomfim, Jan 13 2011