|
|
A372318
|
|
For any n > 0, reverse digits in blocks in balanced ternary expansion of n where blocks are separated by 1's; a(0) = 0.
|
|
2
|
|
|
0, 1, 2, 3, 4, 5, 8, 7, 6, 9, 10, 11, 12, 13, 14, 23, 16, 17, 26, 25, 20, 21, 22, 15, 24, 19, 18, 27, 28, 29, 30, 31, 32, 35, 34, 33, 36, 37, 38, 39, 40, 41, 68, 43, 50, 77, 70, 47, 48, 49, 44, 71, 52, 53, 80, 79, 74, 75, 76, 59, 62, 61, 60, 63, 64, 65, 66, 67
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
0,3
|
|
COMMENTS
|
This sequence is a self-inverse permutation of the nonnegative integers.
This sequence has infinitely many fixed points (A005836, among others).
|
|
LINKS
|
|
|
EXAMPLE
|
For n = 1562: the balanced ternary expansion of 1562 is "1T0110TT" (where T denotes -1), we have three blocks: "T0", "" and "0TT", their reversals are: "0T", "" and "TT0", so the balanced ternary expansion of a(1562) is "10T11TT0", and a(1562) = 2040.
|
|
PROG
|
(PARI) a(n) = { my (d = [], i = 1); while (n, d = concat(centerlift(Mod(n, 3)), d); n = (n - d[1])/3; ); for (j = 2, #d+1, if (j==#d+1 || d[i]==d[j], my (ii = i+1, jj = j-1); while (ii < jj, [d[ii], d[jj]] = [d[jj], d[ii]]; ii++; jj--; ); i = j; ); ); fromdigits(d, 3); }
|
|
CROSSREFS
|
See A372317 for a similar sequence.
|
|
KEYWORD
|
nonn,base
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|