OFFSET
0,2
COMMENTS
d_i(n) can be found using either of the following formulas:
* d_i(n) = floor(n / 3^i) mod 3;
* d_i(n) = floor(n / 3^i) - 3 * floor(n / 3^(i + 1)).
LINKS
James Burling, Table of n, a(n) for n = 0..10000
FORMULA
a(n) = Sum_{i >= 0} p_(i + 1) * (floor(n / 3^i) - 3 * floor(n / 3^(i + 1))).
EXAMPLE
The base 3 representation of n = 5 is 12 so a(5) = 2 * 2 + 1 * 3 = 7.
The base 3 representation of n = 12 is 110 so a(12) = 0 * 2 + 1 * 3 + 1 * 5 = 8.
MATHEMATICA
Table[Sum[IntegerDigits[n, 3][[-i]] Prime@ i, {i, IntegerLength[n, 3]}], {n, 0, 81}] (* Michael De Vlieger, Sep 24 2015 *)
PROG
(PARI) a(n) = my(d = Vecrev(digits(n, 3))); sum(k=1, #d, d[k]*prime(k)); \\ Michel Marcus, Sep 24 2015
CROSSREFS
KEYWORD
nonn,base
AUTHOR
James Burling, Sep 23 2015
STATUS
approved