OFFSET
0,3
COMMENTS
This sequence is a permutation of the nonnegative integers with inverse A321525.
LINKS
FORMULA
a(3 * n) = 3 * a(n).
EXAMPLE
The first terms, alongside the corresponding ternary representations, are:
n a(n) ter(n) ter(a(n))
-- ---- ------ ---------
0 0 0 0
1 1 1 1
2 2 2 2
3 3 10 10
4 4 11 11
5 7 12 21
6 6 20 20
7 5 21 12
8 8 22 22
9 9 100 100
10 10 101 101
11 19 102 201
12 12 110 110
13 13 111 111
14 22 112 211
15 21 120 210
16 14 121 112
17 23 122 212
PROG
(PARI) a(n, base=3) = my (d=digits(n, base), t=select(sign, d), i=-2); for (j=1, #d, if (d[j], d[j]=t[1+(i++%#t)])); fromdigits(d, base)
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Nov 12 2018
STATUS
approved