OFFSET
0,4
COMMENTS
LINKS
Rémy Sigrist, Table of n, a(n) for n = 0..6560
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
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Aug 04 2024
STATUS
approved