cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A004489 Table of tersums m + n (answers written in base 10).

Original entry on oeis.org

0, 1, 1, 2, 2, 2, 3, 0, 0, 3, 4, 4, 1, 4, 4, 5, 5, 5, 5, 5, 5, 6, 3, 3, 6, 3, 3, 6, 7, 7, 4, 7, 7, 4, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 6, 6, 0, 6, 6, 0, 6, 6, 9, 10, 10, 7, 1, 1, 7, 1, 1, 7, 10, 10, 11, 11, 11, 2, 2, 2, 2, 2, 2, 11, 11, 11, 12, 9, 9, 12, 0, 0, 3, 0, 0, 12, 9, 9, 12, 13, 13, 10, 13, 13, 1, 4, 4, 1, 13, 13, 10, 13, 13
Offset: 0

Views

Author

Keywords

Examples

			Table begins:
  0 1 2 3 4 5 6 ...
  1 2 0 4 5 3 7 ...
  2 0 1 5 3 4 8 ...
  3 4 5 6 7 8 0 ...
  4 5 3 7 8 6 1 ...
  5 3 4 8 6 7 2 ...
  6 7 8 0 1 2 3 ...
  ...
		

Crossrefs

Similar to but different from A004481.
Main diagonal gives A004488.
Cf. A003987 (analogous sequence for base 2).

Programs

  • Maple
    T:= proc(n, m) local t, h, r, i;
          t, h, r:= n, m, 0;
          for i from 0 while t>0 or h>0 do
            r:= r +3^i *irem(irem(t, 3, 't') +irem(h, 3, 'h'), 3)
          od; r
        end:
    seq(seq(T(n, d-n), n=0..d), d=0..12);  # Alois P. Heinz, Sep 07 2011
  • Mathematica
    T[n_, m_] := Module[{t, h, r, i, remt, remh}, {t, h, r} = {n, m, 0}; For[i = 0, t>0 || h>0, i++, r = r + 3^i*Mod[({t, remt} = QuotientRemainder[t, 3 ]; remt) + ({h, remh} = QuotientRemainder[h, 3]; remh), 3]]; r]; Table[Table[T[n, d-n], {n, 0, d}], {d, 0, 13}] // Flatten (* Jean-François Alcover, Jan 07 2014, translated from Maple *)
  • PARI
    T(n,m) = fromdigits(Vec(Pol(digits(n,3)) + Pol(digits(m,3)))%3, 3); \\ Kevin Ryde, Apr 06 2021
    
  • Python
    def T(n, m):
      k, pow3 = 0, 1
      while n + m > 0:
        n, rn = divmod(n, 3)
        m, rm = divmod(m, 3)
        k, pow3 = k + pow3*((rn+rm)%3), pow3*3
      return k
    print([T(n, d-n) for d in range(14) for n in range(d+1)]) # Michael S. Branicky, May 04 2021

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.

Extensions

More terms from Larry Reeves (larryr(AT)acm.org), Jan 23 2001