OFFSET
1,3
MATHEMATICA
Total/@Select[IntegerDigits[Range[0, 2000], 3], #==Reverse[#]&] (* Harvey P. Dale, Aug 08 2019 *)
PROG
(Python)
from gmpy2 import digits
def A043262(n):
if n == 1: return 0
y = 3*(x:=3**(len(digits(n>>1, 3))-1))
return int((s:=digits(n-x, 3))[-1])+(sum(int(d) for d in s[:-1])<<1) if n<x+y else sum(map(int, digits(n-y, 3)))<<1 # Chai Wah Wu, Jul 24 2024
CROSSREFS
KEYWORD
nonn,base
AUTHOR
STATUS
approved