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).

This page as a plain text file.
%I A004489 #32 Dec 26 2021 20:57:35
%S A004489 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,
%T A004489 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,
%U A004489 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
%N A004489 Table of tersums m + n (answers written in base 10).
%H A004489 Alois P. Heinz, <a href="/A004489/b004489.txt">Antidiagonals d = 0..140, flattened</a>
%F A004489 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.
%e A004489 Table begins:
%e A004489   0 1 2 3 4 5 6 ...
%e A004489   1 2 0 4 5 3 7 ...
%e A004489   2 0 1 5 3 4 8 ...
%e A004489   3 4 5 6 7 8 0 ...
%e A004489   4 5 3 7 8 6 1 ...
%e A004489   5 3 4 8 6 7 2 ...
%e A004489   6 7 8 0 1 2 3 ...
%e A004489   ...
%p A004489 T:= proc(n, m) local t, h, r, i;
%p A004489       t, h, r:= n, m, 0;
%p A004489       for i from 0 while t>0 or h>0 do
%p A004489         r:= r +3^i *irem(irem(t, 3, 't') +irem(h, 3, 'h'), 3)
%p A004489       od; r
%p A004489     end:
%p A004489 seq(seq(T(n, d-n), n=0..d), d=0..12);  # _Alois P. Heinz_, Sep 07 2011
%t A004489 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 *)
%o A004489 (PARI) T(n,m) = fromdigits(Vec(Pol(digits(n,3)) + Pol(digits(m,3)))%3, 3); \\ _Kevin Ryde_, Apr 06 2021
%o A004489 (Python)
%o A004489 def T(n, m):
%o A004489   k, pow3 = 0, 1
%o A004489   while n + m > 0:
%o A004489     n, rn = divmod(n, 3)
%o A004489     m, rm = divmod(m, 3)
%o A004489     k, pow3 = k + pow3*((rn+rm)%3), pow3*3
%o A004489   return k
%o A004489 print([T(n, d-n) for d in range(14) for n in range(d+1)]) # _Michael S. Branicky_, May 04 2021
%Y A004489 Similar to but different from A004481.
%Y A004489 Main diagonal gives A004488.
%Y A004489 Cf. A003987 (analogous sequence for base 2).
%K A004489 nonn,base,tabl,look,easy,nice
%O A004489 0,4
%A A004489 _N. J. A. Sloane_
%E A004489 More terms from Larry Reeves (larryr(AT)acm.org), Jan 23 2001