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.

A334913 a(n) is the sum of digits of n in signed binary nonadjacent form.

Original entry on oeis.org

0, 1, 1, 0, 1, 2, 0, 0, 1, 2, 2, -1, 0, 1, 0, 0, 1, 2, 2, 1, 2, 3, -1, -1, 0, 1, 1, -1, 0, 1, 0, 0, 1, 2, 2, 1, 2, 3, 1, 1, 2, 3, 3, -2, -1, 0, -1, -1, 0, 1, 1, 0, 1, 2, -1, -1, 0, 1, 1, -1, 0, 1, 0, 0, 1, 2, 2, 1, 2, 3, 1, 1, 2, 3, 3, 0, 1, 2, 1, 1, 2, 3, 3, 2
Offset: 0

Views

Author

Lei Zhou, May 16 2020

Keywords

Crossrefs

Programs

  • Mathematica
    BBN[a_] := Module[{n = a, b}, b = IntegerDigits[n, 2]; b = Prepend[b, 0];
      l = Length[b];
      Do[If[b[[i]] == 2, b[[i]] = 0; b[[i - 1]]++,
        If[b[[i]] == 1,
         If[b[[i + 1]] == 1, b[[i - 1]]++; b[[i]] = 0;
          b[[i + 1]] = -1]]], {i, l - 1, 2, -1}];
      If[b[[1]] == 0, b = Delete[b, 1]]; b]
    Table[a = BBN[i]; sod = 0; l = Length[a];
    Do[sod = sod + a[[j]], {j, 1, l}]; sod, {i, 0, 83}]
  • PARI
    bin2naf(x)=
    { /* Compute (nonadjacent) signed binary representation of x: */
        local(xh, x3, c, np, nm);
        xh = x >> 1;
        x3 = x + xh;
        c = bitxor(xh, x3);
        np = bitand(x3, c);  /* bits == +1 */
        nm = bitand(xh, c);  /* bits == -1 */
        return([np, nm]);  /* np-nm==x */
    }
    a(n) = my(b=bin2naf(n)); return(hammingweight(b[1])-hammingweight(b[2]));
    vector(99,n,a(n-1)) \\ Joerg Arndt, Jun 13 2020

Formula

a(n) = hammingweight(A184615(n)) - hammingweight(A184616(n)). - Joerg Arndt, Jun 13 2020