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-3 of 3 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

A060587 A ternary code: inverse of A060583.

Original entry on oeis.org

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

Views

Author

Henry Bottomley, Apr 04 2001

Keywords

Comments

Write n in base 3, then (working from left to right) if the k-th digit of n is equal to the digit to the left of it then this is the k-th digit of a(n), otherwise the k-th digit of a(n) is the element of {0,1,2} which has not just been compared, then read result as a base 3 number.

Examples

			a(76) = 46 since 76 written in base 3 is 2211; this gives a first digit of 1( = 3-2-0), a second digit of 2( = 2 = 2), a third digit of 0( = 3-1-2) and a fourth digit of 1( = 1 = 1); 1201 base 3 is 46.
		

Crossrefs

Formula

a(n) = 3a([n/3])+(-[n/3]-n mod 3) = 3a([n/3]) + A060588(n).
a(n) = A253586(n,floor(n/3)) = A253587(n,floor(n/3)). - Alois P. Heinz, Jan 09 2015

A253587 The sum of the i-th ternary digits of n, k, and T(n,k) equals 0 (mod 3) for each i>=0 (leading zeros included); triangle T(n,k), n>=0, 0<=k<=n, read by rows.

Original entry on oeis.org

0, 2, 1, 1, 0, 2, 6, 8, 7, 3, 8, 7, 6, 5, 4, 7, 6, 8, 4, 3, 5, 3, 5, 4, 0, 2, 1, 6, 5, 4, 3, 2, 1, 0, 8, 7, 4, 3, 5, 1, 0, 2, 7, 6, 8, 18, 20, 19, 24, 26, 25, 21, 23, 22, 9, 20, 19, 18, 26, 25, 24, 23, 22, 21, 11, 10, 19, 18, 20, 25, 24, 26, 22, 21, 23, 10, 9, 11
Offset: 0

Views

Author

Alois P. Heinz, Jan 04 2015

Keywords

Examples

			Triangle T(n,k) begins:
  0;
  2, 1;
  1, 0, 2;
  6, 8, 7, 3;
  8, 7, 6, 5, 4;
  7, 6, 8, 4, 3, 5;
  3, 5, 4, 0, 2, 1, 6;
  5, 4, 3, 2, 1, 0, 8, 7;
  4, 3, 5, 1, 0, 2, 7, 6, 8;
		

Crossrefs

Column k=0 gives A004488.
Main diagonal gives A001477.
T(n,floor(n/3)) gives A060587.

Programs

  • Maple
    T:= proc(n, k) local i, j; `if`(n=0 and k=0, 0,
          T(iquo(n, 3, 'i'), iquo(k, 3, 'j'))*3 +irem(6-i-j, 3))
        end:
    seq(seq(T(n, k), k=0..n), n=0..14);

Formula

T(n,k) = T(floor(n/3),floor(k/3))*3+(6-(n mod 3)-(k mod 3) mod 3), T(0,0) = 0.
Showing 1-3 of 3 results.