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.
%I A379015 #31 Dec 30 2024 16:08:05 %S A379015 0,1,1,-3,1,5,-3,-7,1,9,5,-19,-3,13,-7,-15,1,17,9,-11,5,21,-19,-35,-3, %T A379015 29,13,-39,-7,25,-15,-31,1,33,17,-23,9,41,-11,-27,5,37,21,-83,-19,45, %U A379015 -35,-67,-3,61,29,-51,13,77,-39,-71,-7,57,25,-79,-15,49,-31,-63 %N A379015 a(n) is the reversed non-adjacent form (NAF) representation of n. %C A379015 Fixed points exist when the non-adjacent form is palindromic. %H A379015 Rémy Sigrist, <a href="/A379015/b379015.txt">Table of n, a(n) for n = 0..10000</a> %H A379015 Wikipedia, <a href="https://en.wikipedia.org/wiki/Non-adjacent_form">Non-adjacent form</a>. %F A379015 a(2^k) = 1. %F A379015 a(A091072(n)) > 0 iff a(n) is in A016813. %F A379015 a(A091067(n)) < 0 iff abs(a(n)) is in A004767. %e A379015 For n=7 a(7) = -7 because: %e A379015 7 to NAF encoding read from least to most significant bit: [-1, 0, 0, 1] %e A379015 Reversed: [1, 0, 0, -1] %e A379015 NAF to integer: -7. %t A379015 a[n_]:=Module[{E=n,r=0},While[E>0,If[OddQ[E],Module[{Zi=2-Mod[E,4]},E-=Zi;r+=Zi;]];E=Floor[E/2];r*=2;];Floor[r/2]];Table[a[n],{n,0,63}] (* _James C. McMahon_, Dec 26 2024 *) %o A379015 (Python) %o A379015 def a(n): %o A379015 E, r = n, 0 %o A379015 while E: %o A379015 if E & 1: %o A379015 Zi = 2 - (E & 3) %o A379015 E -= Zi %o A379015 r += Zi %o A379015 E >>= 1 %o A379015 r <<= 1 %o A379015 return r >> 1 %o A379015 print([a(n) for n in range(0,64)]) %o A379015 (PARI) a(n) = { my (r = 0, d); while (n, if (n%2, d = 2 - (n % 4); r += d; n -= d;); r *= 2; n \= 2;); return (r \ 2); } \\ _Rémy Sigrist_, Dec 28 2024 %Y A379015 Cf. A000079, A004767, A016813, A091067, A091072, A334913. %K A379015 sign,base %O A379015 0,4 %A A379015 _Darío Clavijo_, Dec 13 2024 %E A379015 a(0) = 0 prepended by _Rémy Sigrist_, Dec 28 2024