The OEIS Foundation is supported by donations from users of the OEIS and by a grant from the Simons Foundation.

 Hints (Greetings from The On-Line Encyclopedia of Integer Sequences!)
 A321726 Reverse each run of nonzero digits in ternary expansion of n and convert back to decimal. 2
 0, 1, 2, 3, 4, 7, 6, 5, 8, 9, 10, 11, 12, 13, 22, 21, 16, 25, 18, 19, 20, 15, 14, 23, 24, 17, 26, 27, 28, 29, 30, 31, 34, 33, 32, 35, 36, 37, 38, 39, 40, 67, 66, 49, 76, 63, 64, 65, 48, 43, 70, 75, 52, 79, 54, 55, 56, 57, 58, 61, 60, 59, 62, 45, 46, 47, 42, 41 (list; graph; refs; listen; history; text; internal format)
 OFFSET 0,3 COMMENTS This sequence is a self-inverse permutation of nonnegative integers. LINKS Rémy Sigrist, Table of n, a(n) for n = 0..19683 FORMULA a(3 * n) = 3 * a(n). EXAMPLE For n = 3497: - the ternary representation of 3497 is "11210112", - we replace "1121" by "1211" and "112" by "211" and obtain "12110211", - hence a(3497) = 3991. MATHEMATICA rernz[n_]:=FromDigits[Flatten[If[FreeQ[#, 0], Reverse[#], #]&/@SplitBy[ IntegerDigits[ n, 3], #!=0&]], 3]; Array[rernz, 70, 0] (* Harvey P. Dale, Nov 15 2020 *) PROG (PARI) a(n, base=3) = my (d=digits(n*base, base), nz=0); for (i=1, #d, if (d[i], nz++, if (nz, for (j=1, floor(nz/2), [d[i-j], d[i-nz-1+j]] = [d[i- nz-1+j], d[i-j]]); nz=0))); fromdigits(d, base)/base CROSSREFS See A321464 for a similar sequence. Sequence in context: A072275 A122989 A222246 * A267299 A077223 A265369 Adjacent sequences:  A321723 A321724 A321725 * A321727 A321728 A321729 KEYWORD nonn,base,look AUTHOR Rémy Sigrist, Nov 17 2018 STATUS approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

Last modified August 2 09:22 EDT 2021. Contains 346422 sequences. (Running on oeis4.)