login
A348706
Delete all 0's from ternary expansion of n.
1
1, 2, 1, 4, 5, 2, 7, 8, 1, 4, 5, 4, 13, 14, 5, 16, 17, 2, 7, 8, 7, 22, 23, 8, 25, 26, 1, 4, 5, 4, 13, 14, 5, 16, 17, 4, 13, 14, 13, 40, 41, 14, 43, 44, 5, 16, 17, 16, 49, 50, 17, 52, 53, 2, 7, 8, 7, 22, 23, 8, 25, 26, 7, 22, 23, 22, 67, 68, 23, 70, 71, 8, 25
OFFSET
1,2
LINKS
FORMULA
a(n) <= n with equality iff n belongs to A032924.
EXAMPLE
The first terms, in decimal and in base 3, are:
n a(n) ter(n) ter(a(n))
-- ---- ------ ---------
1 1 1 1
2 2 2 2
3 1 10 1
4 4 11 11
5 5 12 12
6 2 20 2
7 7 21 21
8 8 22 22
9 1 100 1
10 4 101 11
11 5 102 12
12 4 110 11
13 13 111 111
14 14 112 112
15 5 120 12
MATHEMATICA
a[n_] := FromDigits[DeleteCases[IntegerDigits[n, 3], 0], 3]; Array[a, 100] (* Amiram Eldar, Oct 31 2021 *)
PROG
(PARI) a(n, base=3) = fromdigits(select(sign, digits(n, base)), base)
(Python)
from gmpy2 import digits
def A348706(n): return int(digits(n, 3).replace('0', ''), 3) # Chai Wah Wu, Nov 02 2021
CROSSREFS
Cf. A004719 (decimal analog), A032924 (fixed points), A038573 (binary analog).
Sequence in context: A308364 A210707 A078606 * A343250 A065518 A072012
KEYWORD
nonn,base,easy
AUTHOR
Rémy Sigrist, Oct 30 2021
STATUS
approved