OFFSET
0,3
COMMENTS
This sequence is a variant of A334727.
This sequence is a self-inverse permutation of the nonnegative integers that preserves the number of digits and the leading digit in base 3.
LINKS
FORMULA
EXAMPLE
For n = 42: the ternary expansion of 42 is "1120" and the corresponding triangle is as follows:
2
2 2
1 0 1
1 1 2 0
So the ternary expansion of a(42) is "1122", and a(42) = 44.
PROG
(PARI) a(n) = { my (d = digits(n, 3), t = vector(#d)); for (k = 1, #d, t[k] = d[1]; d = vector(#d-1, i, (-d[i]-d[i+1]) % 3); ); fromdigits(t, 3); }
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Mar 26 2023
STATUS
approved