OFFSET
0,2
COMMENTS
This sequence is a self-inverse permutation of the nonnegative integers.
LINKS
EXAMPLE
The first terms, in decimal and in base 3, are:
n a(n) ter(n) ter(a(n))
-- ---- ------ ---------
0 0 0 0
1 2 1 2
2 1 2 1
3 7 10 21
4 8 11 22
5 6 12 20
6 5 20 12
7 3 21 10
8 4 22 11
9 22 100 211
10 23 101 212
11 21 102 210
12 25 110 221
13 26 111 222
14 24 112 220
15 19 120 201
PROG
(PARI) a(n) = { my (d = digits(n, 3)); if (#d, d = if (d[1]==1, apply(v -> [1, 2, 0][1+v], d), apply(v -> [2, 0, 1][1+v], d)); ); fromdigits(d, 3); }
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
Rémy Sigrist, Mar 16 2024
STATUS
approved