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.

This page as a plain text file.
%I A334913 #27 Jul 16 2021 01:34:57
%S A334913 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,
%T A334913 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,
%U A334913 0,1,2,2,1,2,3,1,1,2,3,3,0,1,2,1,1,2,3,3,2
%N A334913 a(n) is the sum of digits of n in signed binary nonadjacent form.
%H A334913 Joerg Arndt, <a href="http://www.jjj.de/fxt/#fxtbook">Matters Computational - Ideas, Algorithms, Source Code</a>, 2011, Springer, pp. 61-62.
%H A334913 Helmut Prodinger, <a href="http://www.emis.de/journals/INTEGERS/papers/a8/a8.Abstract.html">On binary representations of integers with digits -1,0,1</a>, Integers 0 (2000), #A08.
%F A334913 a(n) = hammingweight(A184615(n)) - hammingweight(A184616(n)). - _Joerg Arndt_, Jun 13 2020
%t A334913 BBN[a_] := Module[{n = a, b}, b = IntegerDigits[n, 2]; b = Prepend[b, 0];
%t A334913   l = Length[b];
%t A334913   Do[If[b[[i]] == 2, b[[i]] = 0; b[[i - 1]]++,
%t A334913     If[b[[i]] == 1,
%t A334913      If[b[[i + 1]] == 1, b[[i - 1]]++; b[[i]] = 0;
%t A334913       b[[i + 1]] = -1]]], {i, l - 1, 2, -1}];
%t A334913   If[b[[1]] == 0, b = Delete[b, 1]]; b]
%t A334913 Table[a = BBN[i]; sod = 0; l = Length[a];
%t A334913 Do[sod = sod + a[[j]], {j, 1, l}]; sod, {i, 0, 83}]
%o A334913 (PARI)
%o A334913 bin2naf(x)=
%o A334913 { /* Compute (nonadjacent) signed binary representation of x: */
%o A334913     local(xh, x3, c, np, nm);
%o A334913     xh = x >> 1;
%o A334913     x3 = x + xh;
%o A334913     c = bitxor(xh, x3);
%o A334913     np = bitand(x3, c);  /* bits == +1 */
%o A334913     nm = bitand(xh, c);  /* bits == -1 */
%o A334913     return([np, nm]);  /* np-nm==x */
%o A334913 }
%o A334913 a(n) = my(b=bin2naf(n)); return(hammingweight(b[1])-hammingweight(b[2]));
%o A334913 vector(99,n,a(n-1)) \\ _Joerg Arndt_, Jun 13 2020
%Y A334913 Cf. A000120, A001045, A007302, A184615, A184616.
%K A334913 base,easy,sign
%O A334913 0,6
%A A334913 _Lei Zhou_, May 16 2020