OFFSET
0,4
LINKS
Alois P. Heinz, Table of n, a(n) for n = 0..6560
FORMULA
EXAMPLE
16 = 121_3, replacing 2 with 0 gives 101_3 = 10, so a(16) = 10.
MAPLE
a:= proc(n) local t, r, i; t, r:= n, 0;
for i from 0 while t>0 do
r:= r+3^i*(d-> `if`(d=2, 0, d))(irem(t, 3, 't'))
od; r
end:
seq(a(n), n=0..80); # _Alois P. Heinz_, Jun 17 2014
MATHEMATICA
Array[FromDigits[IntegerDigits[#, 3] /. 2 -> 0, 3] &, 72, 0] (* _Michael De Vlieger_, Mar 17 2018 *)
PROG
(Python)
from sympy.ntheory.factor_ import digits
def a(n):return int("".join(map(str, digits(n, 3)[1:])).replace('2', '0'), 3) # _Indranil Ghosh_, Jun 10 2017
(PARI) a(n) = my(d=digits(n, 3)); fromdigits(apply(x->(if (x==2, 0, x)), d), 3); \\ _Michel Marcus_, Jun 10 2017
CROSSREFS
KEYWORD
AUTHOR
_Joonas Pohjonen_, Jun 17 2014
STATUS
approved