OFFSET
0,1
LINKS
Index entries for linear recurrences with constant coefficients, signature (1,0,0,0,0,0,0,0,1,-1).
FORMULA
Tersum m + n: write m and n in base 3 and add mod 3 with no carries; e.g., 5 + 8 = "21" + "22" = "10" = 1.
MATHEMATICA
LinearRecurrence[{1, 0, 0, 0, 0, 0, 0, 0, 1, -1}, {4, 5, 3, 7, 8, 6, 1, 2, 0, 13, 14}, 80] (* Jinyuan Wang, Mar 10 2020 *)
PROG
(Python)
def tersum(a, b):
c, pow3 = 0, 1
while a + b > 0:
a, ra = divmod(a, 3)
b, rb = divmod(b, 3)
c, pow3 = c + pow3*((ra+rb)%3), pow3*3
return c
def a(n): return tersum(n, 4)
print([a(n) for n in range(58)]) # Michael S. Branicky, Apr 05 2021
(PARI) my(table=[4, 4, 1, 4, 4, 1, -5, -5, -8]); a(n) = n + table[n%9+1]; \\ Kevin Ryde, Apr 05 2021
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
STATUS
approved