OFFSET
0,3
COMMENTS
A permutation of the nonnegative integers with inverse A379658.
LINKS
Rémy Sigrist, Table of n, a(n) for n = 0..10000
Joerg Arndt, Matters Computational (The Fxtbook), pages 61-62.
Wikipedia, Balanced ternary
Wikipedia, Non-adjacent form
EXAMPLE
The first terms are: n a(n) bter(n) naf(a(n))
-- ---- ------- ---------
0 0 0 0
1 1 1 1
2 3 1T 10T
3 2 10 10
4 5 11 101
5 11 1TT 10T0T
6 6 1T0 10T0
7 13 1T1 10T01
8 7 10T 100T
9 4 100 100
10 9 101 1001
11 19 11T 1010T
12 10 110 1010
PROG
(PARI) a(n) = { my (v = 0, d, b = 1); while (n, d = centerlift(Mod(n, 3)); n = (n-d)/3;
v += d * b; b *= if (d, 4, 2); ); v; }
CROSSREFS
KEYWORD
nonn,base,new
AUTHOR
Rémy Sigrist, Dec 29 2024
STATUS
approved