login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

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.
2
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,4
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.
LINKS
FORMULA
a(n) <= n.
a(a(n)) = a(n).
EXAMPLE
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
PROG
(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); }
CROSSREFS
Cf. A134025, A371268, A373696 (decimal analog).
Sequence in context: A092910 A356334 A322347 * A073322 A006197 A079404
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Aug 04 2024
STATUS
approved