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

A321474 Reverse the nonzero digits of n.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 21, 31, 41, 51, 61, 71, 81, 91, 20, 12, 22, 32, 42, 52, 62, 72, 82, 92, 30, 13, 23, 33, 43, 53, 63, 73, 83, 93, 40, 14, 24, 34, 44, 54, 64, 74, 84, 94, 50, 15, 25, 35, 45, 55, 65, 75, 85, 95, 60, 16, 26, 36, 46, 56, 66, 76
Offset: 0

Views

Author

Rémy Sigrist, Nov 11 2018

Keywords

Comments

This sequence is a self-inverse permutation of nonnegative integers.
See A321464 for the ternary variant.
This sequence has similarities with A069799: here we reverse nonzero digits, there we reverse nonzero prime exponents.

Examples

			For n = 1024:
- 1024 has 3 nonzero digits: 1, 2 and 4,
- so we replace the first nonzero digit by the third, the third by the first (and the second remains in place),
- and we obtain a(1024) = 4021.
		

Crossrefs

Programs

  • PARI
    a(n, base=10) = my (d=digits(n, base), t=Vecrev(select(sign, d)), i=0); for (j=1, #d, if (d[j], d[j] = t[i++])); fromdigits(d, base)

Formula

a(10 * n) = 10 * a(n).
A136400(a(n)) = A136400(n).

A321473 Nonnegative numbers whose nonzero digits in ternary expansion are palindromic.

Original entry on oeis.org

0, 1, 2, 3, 4, 6, 8, 9, 10, 12, 13, 16, 18, 20, 23, 24, 26, 27, 28, 30, 31, 34, 36, 37, 39, 40, 46, 48, 52, 54, 56, 59, 60, 62, 65, 68, 69, 72, 74, 78, 80, 81, 82, 84, 85, 88, 90, 91, 93, 94, 100, 102, 106, 108, 109, 111, 112, 117, 118, 120, 121, 130, 136, 138
Offset: 1

Views

Author

Rémy Sigrist, Nov 11 2018

Keywords

Comments

This sequence corresponds to the fixed points of A321464, and contains A014190.

Examples

			For n = 1594426:
- the ternary expansion of 1594426 is "10000000010211",
- the corresponding nonzero digits are "11211", which are palindromic,
- hence 1594426 belongs to the sequence.
		

Crossrefs

Programs

  • Mathematica
    Select[Range[0,200],PalindromeQ[FromDigits[IntegerDigits[#,3]/.(0-> Nothing)]]&] (* Requires Mathematica version 10 or later *) (* Harvey P. Dale, Jun 22 2020 *)
  • PARI
    is(n, base=3) = my (t=select(sign, digits(n, base))); t==Vecrev(t)

A321524 Right-rotate nonzero digits in ternary expansion of n and convert back to decimal.

Original entry on oeis.org

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

Views

Author

Rémy Sigrist, Nov 12 2018

Keywords

Comments

This sequence is a permutation of the nonnegative integers with inverse A321525.

Examples

			The first terms, alongside the corresponding ternary representations, are:
  n   a(n)  ter(n)  ter(a(n))
  --  ----  ------  ---------
   0     0       0          0
   1     1       1          1
   2     2       2          2
   3     3      10         10
   4     4      11         11
   5     7      12         21
   6     6      20         20
   7     5      21         12
   8     8      22         22
   9     9     100        100
  10    10     101        101
  11    19     102        201
  12    12     110        110
  13    13     111        111
  14    22     112        211
  15    21     120        210
  16    14     121        112
  17    23     122        212
		

Crossrefs

Cf. A321464, A321525 (inverse).

Programs

  • PARI
    a(n, base=3) = my (d=digits(n, base), t=select(sign, d), i=-2); for (j=1, #d, if (d[j], d[j]=t[1+(i++%#t)])); fromdigits(d, base)

Formula

a(3 * n) = 3 * a(n).

A321525 Left-rotate nonzero digits in ternary expansion of n and convert back to decimal.

Original entry on oeis.org

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

Views

Author

Rémy Sigrist, Nov 13 2018

Keywords

Comments

This sequence is a permutation of the nonnegative integers with inverse A321524.

Examples

			The first terms, alongside the corresponding ternary representations, are:
  n   a(n)  ter(n)  ter(a(n))
  --  ----  ------  ---------
   0     0       0          0
   1     1       1          1
   2     2       2          2
   3     3      10         10
   4     4      11         11
   5     7      12         21
   6     6      20         20
   7     5      21         12
   8     8      22         22
   9     9     100        100
  10    10     101        101
  11    19     102        201
  12    12     110        110
  13    13     111        111
  14    16     112        121
  15    21     120        210
  16    22     121        211
  17    25     122        221
		

Crossrefs

Cf. A321464, A321524 (inverse).

Programs

  • PARI
    a(n, base=3) = my (d=digits(n, base), t=select(sign, d), i=0); for (j=1, #d, if (d[j], d[j]=t[1+(i++%#t)])); fromdigits(d, base)

Formula

a(3 * n) = 3 * a(n).

A321726 Reverse each run of nonzero digits in ternary expansion of n and convert back to decimal.

Original entry on oeis.org

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

Views

Author

Rémy Sigrist, Nov 17 2018

Keywords

Comments

This sequence is a self-inverse permutation of nonnegative integers.

Examples

			For n = 3497:
- the ternary representation of 3497 is "11210112",
- we replace "1121" by "1211" and "112" by "211" and obtain "12110211",
- hence a(3497) = 3991.
		

Crossrefs

See A321464 for a similar sequence.

Programs

  • Mathematica
    rernz[n_]:=FromDigits[Flatten[If[FreeQ[#,0],Reverse[#],#]&/@SplitBy[ IntegerDigits[ n,3],#!=0&]],3]; Array[rernz,70,0] (* Harvey P. Dale, Nov 15 2020 *)
  • PARI
    a(n, base=3) = my (d=digits(n*base, base), nz=0); for (i=1, #d, if (d[i], nz++, if (nz, for (j=1, floor(nz/2), [d[i-j],d[i-nz-1+j]] = [d[i-nz-1+j],d[i-j]]); nz=0))); fromdigits(d, base)/base

Formula

a(3 * n) = 3 * a(n).
Showing 1-6 of 6 results.