OFFSET
0,3
COMMENTS
This sequence is a self-inverse permutation of the nonnegative integers.
LINKS
FORMULA
a(n) = n iff n belongs to A062318.
EXAMPLE
For n = 42: the ternary expansion of 42 is "1120", so the ternary expansion of a(42) is "1021", and a(42) = 34.
MATHEMATICA
Table[t3=IntegerDigits[n, 3]; fd=First[t3]; tr=Rest[t3]/.{1->0, 0->1}; PrependTo[tr, fd]; FromDigits[tr, 3], {n, 0, 67}] (* James C. McMahon, May 31 2024 *)
PROG
(PARI) a(n) = { my (t = digits(n, 3)); for (i = 2, #t, t[i] = [1, 0, 2][1+t[i]]; ); fromdigits(t, 3); }
CROSSREFS
KEYWORD
AUTHOR
Rémy Sigrist, May 13 2024
STATUS
approved