OFFSET
0,3
COMMENTS
LINKS
FORMULA
a(3 * n) = 3 * a(n).
EXAMPLE
The first values at prime indices, alongside the corresponding ternary expansions, are:
n a(n) ter(n) ter(a(n))
-- ---- ------ ---------
2 2 2 2
3 3 10 10
5 7 12 21
7 5 21 12
11 19 102 201
13 13 111 111
17 25 122 221
19 11 201 102
23 23 212 212
29 55 1002 2001
31 31 1011 1011
37 37 1101 1101
41 67 1112 2111
43 49 1121 1211
MATHEMATICA
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 *)
PROG
(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)
CROSSREFS
KEYWORD
AUTHOR
Rémy Sigrist, Nov 10 2018
STATUS
approved