OFFSET
0,3
COMMENTS
LINKS
EXAMPLE
The first terms, alongside their balanced ternary expansion (with T's standing for -1's), are:
n a(n) bter(n) bter(a(n))
-- ---- ------- ----------
0 0 0 0
1 1 1 1
2 3 1T 10
3 4 10 11
4 2 11 1T
5 8 1TT 10T
6 9 1T0 100
7 10 1T1 101
8 12 10T 110
9 13 100 111
10 11 101 11T
11 7 11T 1T1
12 5 110 1TT
13 6 111 1T0
14 25 1TTT 10T1
15 23 1TT0 10TT
16 24 1TT1 10T0
PROG
(PARI) a(n) = { my (d=[], s=Mod(0, 3)); while (n, my (t=centerlift(Mod(n, 3))); n=(n-t)\3; d=concat(t, d)); for (k=1, #d, d[k] = centerlift(s+=d[k])); fromdigits(d, 3) }
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Apr 25 2021
STATUS
approved