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.

Showing 1-9 of 9 results.

A004488 Tersum n + n.

Original entry on oeis.org

0, 2, 1, 6, 8, 7, 3, 5, 4, 18, 20, 19, 24, 26, 25, 21, 23, 22, 9, 11, 10, 15, 17, 16, 12, 14, 13, 54, 56, 55, 60, 62, 61, 57, 59, 58, 72, 74, 73, 78, 80, 79, 75, 77, 76, 63, 65, 64, 69, 71, 70, 66, 68, 67, 27, 29, 28, 33, 35, 34, 30, 32, 31, 45, 47, 46, 51
Offset: 0

Views

Author

Keywords

Comments

Could also be described as "Write n in base 3, then replace each digit with its base-3 negative" as with A048647 for base 4. - Henry Bottomley, Apr 19 2000
a(a(n)) = n, a self-inverse permutation of the nonnegative integers. - Reinhard Zumkeller, Dec 19 2003
First 3^n terms of the sequence form a permutation s(n) of 0..3^n-1, n>=1; the number of inversions of s(n) is A016142(n-1). - Gheorghe Coserea, Apr 23 2018

Crossrefs

Programs

  • Haskell
    a004488 0 = 0
    a004488 n = if d == 0 then 3 * a004488 n' else 3 * a004488 n' + 3 - d
                where (n', d) = divMod n 3
    -- Reinhard Zumkeller, Mar 12 2014
    
  • Maple
    a:= proc(n) local t, r, i;
          t, r:= n, 0;
          for i from 0 while t>0 do
            r:= r+3^i *irem(2*irem(t, 3, 't'), 3)
          od; r
        end:
    seq(a(n), n=0..80);  # Alois P. Heinz, Sep 07 2011
  • Mathematica
    a[n_] := FromDigits[Mod[3-IntegerDigits[n, 3], 3], 3]; Table[a[n], {n, 0, 66}] (* Jean-François Alcover, Mar 03 2014 *)
  • PARI
    a(n) = my(b=3); fromdigits(apply(d->(b-d)%b, digits(n, b)), b);
    vector(67, i, a(i-1))  \\ Gheorghe Coserea, Apr 23 2018
    
  • Python
    from sympy.ntheory.factor_ import digits
    def a(n): return int("".join([str((3 - i)%3) for i in digits(n, 3)[1:]]), 3) # Indranil Ghosh, Jun 06 2017

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.
a(n) = Sum(3-d(i)-3*0^d(i): n=Sum(d(i)*3^d(i): 0<=d(i)<3)). - Reinhard Zumkeller, Dec 19 2003
a(3*n) = 3*a(n), a(3*n+1) = 3*a(n)+2, a(3*n+2) = 3*a(n)+1. - Robert Israel, May 09 2014

A004481 Table of Sprague-Grundy values for Wythoff's game (Wyt Queens) read by antidiagonals.

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, 2, 2, 4, 7, 7, 8, 8, 8, 0, 7, 0, 8, 8, 8, 9, 6, 6, 1, 6, 6, 1, 6, 6, 9, 10, 10, 7, 9, 9, 8, 9, 9, 7, 10, 10, 11, 11, 11, 10, 0, 10, 10, 0, 10, 11, 11, 11, 12, 9, 9, 12, 1, 1, 3, 1, 1, 12, 9, 9, 12
Offset: 0

Views

Author

Keywords

Comments

T(a,b) = T(b,a).

Examples

			Table begins
   0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, ...
   1,  2,  0,  4,  5,  3,  7,  8,  6, 10, 11,  9, ...
   2,  0,  1,  5,  3,  4,  8,  6,  7, 11,  9, ...
   3,  4,  5,  6,  2,  0,  1,  9, 10, 12, ...
   4,  5,  3,  2,  7,  6,  9,  0,  1, ...
   5,  3,  4,  0,  6,  8, 10,  1, ...
   6,  7,  8,  1,  9, 10,  3, ...
   7,  8,  6,  9,  0,  1, ...
   8,  6,  7, 10,  1, ...
   9, 10, 11, 12, ...
  10, 11,  9, ...
  11,  9, ...
  12, ...
  ...
		

References

  • E. R. Berlekamp, J. H. Conway and R. K. Guy, Winning Ways, Academic Press, NY, 2 vols., 1982, see p. 76.
  • Eric Friedman, Scott M. Garrabrant, Ilona K. Phipps-Morgan, A. S. Landsberg and Urban Larsson, Geometric analysis of a generalized Wythoff game, in Games of no Chance 5, MSRI publ. Cambridge University Press, date?
  • R. K. Guy, The unity of combinatorics, Proc. 25th Iranian Math. Conf, Tehran, (1994), Math. Appl 329 129-159, Kluwer Dordrecht 1995, Math. Rev. 96k:05001.

Crossrefs

A004482-A004487 are rows 1 to 6. Cf. A047708 (main diagonal).
See A317205 for triangle of values on or below main diagonal.
Similar to but different from A004489.
T(a, b)=0 iff A018219(a, b)=0 iff A002251(a)=b.

Programs

  • Mathematica
    mex[list_] := mex[list] = Min[Complement[Range[0, Length[list]], list]];
    move[Wnim, {a_, b_}] := move[Wnim, {a, b}] =
       Union[Table[{i, b}, {i, 0, a - 1}], Table[{a, i}, {i, 0, b - 1}],
        Table[{a - i, b - i}, {i, 1, Min[a, b]}]];
    SpragueGrundy[game_, list_] := SpragueGrundy[game, list] =
       mex[SpragueGrundy[game, #] & /@ move[game, list]];
    t[n_, m_] := SpragueGrundy[Wnim, {n - 1, m - 1}];
    Flatten@Table[t[n - m + 1, m], {n, 11}, {m, n}] (* Birkas Gyorgy, Apr 19 2011 *)
  • PARI
    See Links section.

A004493 Tersum n + 4.

Original entry on oeis.org

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
Offset: 0

Views

Author

Keywords

Crossrefs

Cf. A004489 (tersum array).

Programs

  • 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 *)
  • PARI
    my(table=[4,4,1,4,4,1,-5,-5,-8]); a(n) = n + table[n%9+1]; \\ Kevin Ryde, Apr 05 2021
  • 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
    

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.

A004494 Tersum n + 5.

Original entry on oeis.org

5, 3, 4, 8, 6, 7, 2, 0, 1, 14, 12, 13, 17, 15, 16, 11, 9, 10, 23, 21, 22, 26, 24, 25, 20, 18, 19, 32, 30, 31, 35, 33, 34, 29, 27, 28, 41, 39, 40, 44, 42, 43, 38, 36, 37, 50, 48, 49, 53, 51, 52, 47, 45, 46, 59, 57, 58, 62, 60, 61, 56, 54, 55, 68, 66, 67, 71, 69
Offset: 0

Views

Author

Keywords

Crossrefs

Cf. A004489.

Programs

  • Mathematica
    LinearRecurrence[{1, 0, 0, 0, 0, 0, 0, 0, 1, -1}, {5, 3, 4, 8, 6, 7,
    2, 0, 1, 14}, 80] (* Jinyuan Wang, Mar 10 2020 *)
  • Python
    # T(n, m) in A004489
    def a(n): return T(n, 5)
    print([a(n) for n in range(68)]) # Michael S. Branicky, May 03 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.

A059249 Tersum n + (n-1); write n and n-1 in base 3 and add mod 3 with no carries.

Original entry on oeis.org

1, 0, 5, 7, 6, 2, 4, 3, 17, 19, 18, 23, 25, 24, 20, 22, 21, 8, 10, 9, 14, 16, 15, 11, 13, 12, 53, 55, 54, 59, 61, 60, 56, 58, 57, 71, 73, 72, 77, 79, 78, 74, 76, 75, 62, 64, 63, 68, 70, 69, 65, 67, 66, 26, 28, 27, 32, 34, 33, 29, 31, 30, 44, 46, 45, 50, 52, 51, 47, 49, 48, 35
Offset: 1

Views

Author

Henry Bottomley, Jan 22 2001

Keywords

Examples

			a(21)=14 since 21 and 20 are written in base 3 as 210 and 202 and so their tersum is 112 in base 3, i.e. 9+3+2=14.
		

Crossrefs

A343836 Array T(n, k), n, k > 0, read by antidiagonals; the balanced ternary representation of T(n, k) is obtained by adding componentwise (i.e., without carries) the digits in the balanced ternary representations of n and of k.

Original entry on oeis.org

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

Views

Author

Rémy Sigrist, May 01 2021

Keywords

Comments

This sequence is similar to A003987 and to A004489.
We use the following table to combine individual digits (this is the balanced ternary addition table read mod 3):
| T 0 1
---+-------
T | 1 T 0
0 | T 0 1
1 | 0 1 T

Examples

			Array T(n, k) begins:
  n\k|   0   1   2   3   4    5    6    7    8    9   10   11   12   13
  ---+-----------------------------------------------------------------
    0|   0   1   2   3   4    5    6    7    8    9   10   11   12   13
    1|   1  -1   3   4   2    6    7    5    9   10    8   12   13   11
    2|   2   3  -2  -4  -3   10    8    9   13   11   12    7    5    6
    3|   3   4  -4  -3  -2    8    9   10   11   12   13    5    6    7
    4|   4   2  -3  -2  -4    9   10    8   12   13   11    6    7    5
    5|   5   6  10   8   9   -5   -7   -6  -11  -13  -12   -8  -10   -9
    6|   6   7   8   9  10   -7   -6   -5  -13  -12  -11  -10   -9   -8
    7|   7   5   9  10   8   -6   -5   -7  -12  -11  -13   -9   -8  -10
    8|   8   9  13  11  12  -11  -13  -12   -8  -10   -9   -5   -7   -6
    9|   9  10  11  12  13  -13  -12  -11  -10   -9   -8   -7   -6   -5
   10|  10   8  12  13  11  -12  -11  -13   -9   -8  -10   -6   -5   -7
   11|  11  12   7   5   6   -8  -10   -9   -5   -7   -6  -11  -13  -12
   12|  12  13   5   6   7  -10   -9   -8   -7   -6   -5  -13  -12  -11
   13|  13  11   6   7   5   -9   -8  -10   -6   -5   -7  -12  -11  -13
Array T(n, k) begins in balanced ternary:
  n\k|    0    1   1T   10   11  1TT  1T0  1T1  10T  100  101  11T  110  111
  ---+----------------------------------------------------------------------
    0|    0    1   1T   10   11  1TT  1T0  1T1  10T  100  101  11T  110  111
    1|    1    T   10   11   1T  1T0  1T1  1TT  100  101  10T  110  111  11T
   1T|   1T   10   T1   TT   T0  101  10T  100  111  11T  110  1T1  1TT  1T0
   10|   10   11   TT   T0   T1  10T  100  101  11T  110  111  1TT  1T0  1T1
   11|   11   1T   T0   T1   TT  100  101  10T  110  111  11T  1T0  1T1  1TT
  1TT|  1TT  1T0  101  10T  100  T11  T1T  T10  TT1  TTT  TT0  T01  T0T  T00
  1T0|  1T0  1T1  10T  100  101  T1T  T10  T11  TTT  TT0  TT1  T0T  T00  T01
  1T1|  1T1  1TT  100  101  10T  T10  T11  T1T  TT0  TT1  TTT  T00  T01  T0T
  10T|  10T  100  111  11T  110  TT1  TTT  TT0  T01  T0T  T00  T11  T1T  T10
  100|  100  101  11T  110  111  TTT  TT0  TT1  T0T  T00  T01  T1T  T10  T11
  101|  101  10T  110  111  11T  TT0  TT1  TTT  T00  T01  T0T  T10  T11  T1T
  11T|  11T  110  1T1  1TT  1T0  T01  T0T  T00  T11  T1T  T10  TT1  TTT  TT0
  110|  110  111  1TT  1T0  1T1  T0T  T00  T01  T1T  T10  T11  TTT  TT0  TT1
  111|  111  11T  1T0  1T1  1TT  T00  T01  T0T  T10  T11  T1T  TT0  TT1  TTT
		

Crossrefs

Programs

  • PARI
    T(n,k,c=v->centerlift(Mod(v,3))) = { if (n==0 && k==0, return (0), my (d=c(n), t=c(k)); c(d+t)+3*T((n-d)/3, (k-t)/3)) }

Formula

T(n, k) = T(k, n).
T(m, T(n, k)) = T(T(m, n), k).
T(n, 0) = n.
T(n, n) = -n.

A004500 Tersum n + 11.

Original entry on oeis.org

11, 9, 10, 14, 12, 13, 17, 15, 16, 20, 18, 19, 23, 21, 22, 26, 24, 25, 2, 0, 1, 5, 3, 4, 8, 6, 7, 38, 36, 37, 41, 39, 40, 44, 42, 43, 47, 45, 46, 50, 48, 49, 53, 51, 52, 29, 27, 28, 32, 30, 31, 35, 33, 34, 65, 63, 64, 68, 66, 67, 71, 69, 70, 74, 72, 73, 77, 75
Offset: 0

Views

Author

Keywords

Crossrefs

Cf. A004489.

Programs

  • Python
    def a(n):
        k, pow3, m = 0, 1, 11
        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([a(n) for n in range(58)]) # Michael S. Branicky, Nov 09 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.
a(n) = A004489(n, 11). - Michel Marcus, Nov 09 2021
G.f.: (20*x^21+x^20-2*x^19-16*x^18-7*x^12+x^11-2*x^10+11*x^9-7*x^3+x^2-2*x+11) / ((x^2+x+1)*(x^18+x^9+1)*(x-1)^2). - Alois P. Heinz, Nov 09 2021

A004501 Tersum n + 12.

Original entry on oeis.org

12, 13, 14, 15, 16, 17, 9, 10, 11, 21, 22, 23, 24, 25, 26, 18, 19, 20, 3, 4, 5, 6, 7, 8, 0, 1, 2, 39, 40, 41, 42, 43, 44, 36, 37, 38, 48, 49, 50, 51, 52, 53, 45, 46, 47, 30, 31, 32, 33, 34, 35, 27, 28, 29, 66, 67, 68, 69
Offset: 0

Views

Author

Keywords

Crossrefs

Cf. A004489.

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.

A004502 Tersum n + 13.

Original entry on oeis.org

13, 14, 12, 16, 17, 15, 10, 11, 9, 22, 23, 21, 25, 26, 24, 19, 20, 18, 4, 5, 3, 7, 8, 6, 1, 2, 0, 40, 41, 39, 43, 44, 42, 37, 38, 36, 49, 50, 48, 52, 53, 51, 46, 47, 45, 31, 32, 30, 34, 35, 33, 28, 29, 27, 67, 68, 66, 70
Offset: 0

Views

Author

Keywords

Crossrefs

Cf. A004489.

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.
Showing 1-9 of 9 results.