

A321767


Reverse runs of nonzero digits in ternary expansion of n and convert back to decimal.


1



0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 19, 12, 13, 14, 15, 16, 17, 18, 11, 20, 21, 22, 23, 24, 25, 26, 27, 28, 55, 30, 37, 46, 57, 64, 73, 36, 31, 58, 39, 40, 41, 42, 43, 44, 45, 32, 59, 48, 49, 50, 51, 52, 53, 54, 29, 56, 33, 38, 47, 60, 65, 74, 63, 34, 61, 66, 67
(list;
graph;
refs;
listen;
history;
text;
internal format)



OFFSET

0,3


COMMENTS

This sequence is a selfinverse permutation of nonnegative integers.


LINKS



FORMULA

a(3 * n) = 3 * a(n).


EXAMPLE

For n = 11111:
 the ternary representation of 11111 is "120020112",
 we have three runs of nonzero digits: "12", "2" and "112",
 we replace the first by the third, the third by the first and the second remains in place,
 the result is: "112002012",
 and a(11111) = 10265.


PROG

(PARI) See Links section.


CROSSREFS

See A321726 for a similar sequence.


KEYWORD



AUTHOR



STATUS

approved



