login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

The nonadjacent form of a(n) is obtained by inserting a digit 0 before each nonzero digit in the balanced ternary expansion of n.
2

%I #10 Dec 30 2024 16:07:38

%S 0,1,3,2,5,11,6,13,7,4,9,19,10,21,43,22,45,23,12,25,51,26,53,27,14,29,

%T 15,8,17,35,18,37,75,38,77,39,20,41,83,42,85,171,86,173,87,44,89,179,

%U 90,181,91,46,93,47,24,49,99,50,101,203,102,205,103,52,105

%N The nonadjacent form of a(n) is obtained by inserting a digit 0 before each nonzero digit in the balanced ternary expansion of n.

%C A permutation of the nonnegative integers with inverse A379658.

%H Rémy Sigrist, <a href="/A379657/b379657.txt">Table of n, a(n) for n = 0..10000</a>

%H Joerg Arndt, <a href="http://www.jjj.de/fxt/#fxtbook">Matters Computational (The Fxtbook)</a>, pages 61-62.

%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Balanced_ternary">Balanced ternary</a>

%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Non-adjacent_form">Non-adjacent form</a>

%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>

%F A334913(a(n)) = A065363(n).

%e The first terms are: n a(n) bter(n) naf(a(n))

%e -- ---- ------- ---------

%e 0 0 0 0

%e 1 1 1 1

%e 2 3 1T 10T

%e 3 2 10 10

%e 4 5 11 101

%e 5 11 1TT 10T0T

%e 6 6 1T0 10T0

%e 7 13 1T1 10T01

%e 8 7 10T 100T

%e 9 4 100 100

%e 10 9 101 1001

%e 11 19 11T 1010T

%e 12 10 110 1010

%o (PARI) a(n) = { my (v = 0, d, b = 1); while (n, d = centerlift(Mod(n, 3)); n = (n-d)/3;

%o v += d * b; b *= if (d, 4, 2);); v; }

%Y See A048680 for a similar sequence.

%Y Cf. A065363, A334913, A379658 (inverse).

%K nonn,base

%O 0,3

%A _Rémy Sigrist_, Dec 29 2024