login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A004493 Tersum n + 4. 2
4, 5, 3, 7, 8, 6, 1, 2, 0, 13, 14, 12, 16, 17, 15, 10, 11, 9, 22, 23, 21, 25, 26, 24, 19, 20, 18, 31, 32, 30, 34, 35, 33, 28, 29, 27, 40, 41, 39, 43, 44, 42, 37, 38, 36, 49, 50, 48, 52, 53, 51, 46, 47, 45, 58, 59, 57, 61 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,1
LINKS
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
Cf. A004489 (tersum array).
Sequence in context: A196402 A268741 A263031 * A348051 A328238 A170929
KEYWORD
nonn,easy
AUTHOR
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 25 13:44 EDT 2024. Contains 371975 sequences. (Running on oeis4.)