OFFSET
0,3
COMMENTS
This sequence can be extended to negative indexes by setting a(-n) = -a(n) for any n > 0. We then obtain a permutation of the integers (Z) with inverse A343602 (after a similar extension to negative indexes).
LINKS
Rémy Sigrist, Table of n, a(n) for n = 0..9841
FORMULA
EXAMPLE
The first terms, in base 10 and in balanced ternary (where T denotes the digit -1), are:
n a(n) bter(n) bter(a(n))
-- ---- ------- ----------
0 0 0 0
1 1 1 1
2 -2 1T T1
3 3 10 10
4 4 11 11
5 -7 1TT T1T
6 -8 1T0 T01
7 11 1T1 11T
8 -6 10T T10
9 9 100 100
10 12 101 110
11 -5 11T T11
12 10 110 101
13 13 111 111
14 -22 1TTT T1TT
15 -25 1TT0 T01T
PROG
(PARI) a(n) = { my (d = [], t); while (n, d = concat(t = centerlift(Mod(n, 3)), d); n = (n-t)\3); forstep (k=#d, 1, -1, if (d[k], return (fromdigits(concat(d[k..#d], d[1..k-1]), 3)))); return (fromdigits(d, 3)) }
CROSSREFS
KEYWORD
sign,base
AUTHOR
Rémy Sigrist, Apr 21 2021
STATUS
approved