cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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

This page as a plain text file.
%I A321464 #18 Sep 17 2019 08:31:05
%S A321464 0,1,2,3,4,7,6,5,8,9,10,19,12,13,22,21,16,25,18,11,20,15,14,23,24,17,
%T A321464 26,27,28,55,30,31,58,57,34,61,36,37,64,39,40,67,66,49,76,63,46,73,48,
%U A321464 43,70,75,52,79,54,29,56,33,32,59,60,35,62,45,38,65,42,41
%N A321464 Reverse nonzero digits in ternary expansion of n and convert back to decimal.
%C A321464 This sequence is a self-inverse permutation of nonnegative integers with fixed points A321473.
%C A321464 See A321474 for the decimal variant.
%C A321464 The binary variant simply corresponds to the identity (A001477).
%H A321464 Rémy Sigrist, <a href="/A321464/b321464.txt">Table of n, a(n) for n = 0..19683</a>
%H A321464 <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%F A321464 a(3 * n) = 3 * a(n).
%e A321464 The first values at prime indices, alongside the corresponding ternary expansions, are:
%e A321464   n   a(n)  ter(n)  ter(a(n))
%e A321464   --  ----  ------  ---------
%e A321464    2     2       2          2
%e A321464    3     3      10         10
%e A321464    5     7      12         21
%e A321464    7     5      21         12
%e A321464   11    19     102        201
%e A321464   13    13     111        111
%e A321464   17    25     122        221
%e A321464   19    11     201        102
%e A321464   23    23     212        212
%e A321464   29    55    1002       2001
%e A321464   31    31    1011       1011
%e A321464   37    37    1101       1101
%e A321464   41    67    1112       2111
%e A321464   43    49    1121       1211
%t A321464 a[n_] := Block[{x = IntegerDigits[n, 3], t}, t = Flatten@ Position[x, 1 | 2]; x[[Reverse@ t]] = x[[t]]; FromDigits[x, 3]]; Array[a, 68, 0] (* _Giovanni Resta_, Sep 17 2019 *)
%o A321464 (PARI) a(n,base=3) = my (d=digits(n,base),t=Vecrev(select(sign,d)),i=0); for (j=1, #d, if (d[j], d[j] = t[i++])); fromdigits(d,base)
%Y A321464 Cf. A001477, A004488, A030102, A321473, A321474.
%K A321464 nonn,base,look
%O A321464 0,3
%A A321464 _Rémy Sigrist_, Nov 10 2018