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.

A373712 a(n) is the least m >= 0 with the same number of ternary digits as n such that for some permutation p of 0..2, applying p to the ternary digits of n yields the ternary digits of m.

Original entry on oeis.org

0, 1, 1, 3, 4, 3, 3, 3, 4, 9, 10, 11, 12, 13, 12, 11, 10, 9, 9, 11, 10, 11, 9, 10, 12, 12, 13, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 27, 29, 28, 33, 35, 34, 30, 32, 31, 35, 33, 34, 29, 27
Offset: 0

Views

Author

Rémy Sigrist, Aug 04 2024

Keywords

Comments

Leading zeros in ternary expansions are ignored.
Empirically, A134025 corresponds to the fixed points of this sequence.
The lexicographically latest sequence b of distinct nonnegative integers such that for any n >= 0, a(n) = a(b(n)) is A371268.

Examples

			The first terms, alongside their ternary expansions, are:
  n   a(n)  ter(n)  ter(a(n))
  --  ----  ------  ---------
   0     0       0          0
   1     1       1          1
   2     1       2          1
   3     3      10         10
   4     4      11         11
   5     3      12         10
   6     3      20         10
   7     3      21         10
   8     4      22         11
   9     9     100        100
  10    10     101        101
  11    11     102        102
  12    12     110        110
  13    13     111        111
  14    12     112        110
  15    11     120        102
  16    10     121        101
		

Crossrefs

Cf. A134025, A371268, A373696 (decimal analog).

Programs

  • PARI
    a(n, base = 3) = { my (d = digits(n, base), m = vector(base, i, -1), u = 1); for (i = 1, #d, if (m[1+d[i]] < 0, m[1+d[i]] = u; u = if (u==1, 0, u==0, 2, u+1);); d[i] = m[1+d[i]];); fromdigits(d, base); }

Formula

a(n) <= n.
a(a(n)) = a(n).