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.

A380180 Irregular table T(n, k), n >= 0, k = 1..2^A005812(n); the n-th row lists the integers m (possibly negative) such that the nonzero digits in the balanced ternary expansion of m appear in the balanced ternary expansion of n.

Original entry on oeis.org

0, 0, 1, -1, 0, 2, 3, 0, 3, 0, 1, 3, 4, -4, -3, -1, 0, 5, 6, 8, 9, -3, 0, 6, 9, -3, -2, 0, 1, 6, 7, 9, 10, -1, 0, 8, 9, 0, 9, 0, 1, 9, 10, -1, 0, 2, 3, 8, 9, 11, 12, 0, 3, 9, 12, 0, 1, 3, 4, 9, 10, 12, 13, -13, -12, -10, -9, -4, -3, -1, 0, 14, 15, 17, 18, 23, 24, 26, 27
Offset: 0

Views

Author

Rémy Sigrist, Jan 15 2025

Keywords

Comments

Every integer appears infinitely many times in the sequence.
See A368239 (resp. A380181) for the nonnegative values (resp. the nonpositive values, negated) in order of appearance in the present sequence.

Examples

			Irregular table T(n, k) begins:
  n   n-th row
  --  -------------------------
   0  0
   1  0, 1
   2  -1, 0, 2, 3
   3  0, 3
   4  0, 1, 3, 4
   5  -4, -3, -1, 0, 5, 6, 8, 9
   6  -3, 0, 6, 9
   7  -3, -2, 0, 1, 6, 7, 9, 10
   8  -1, 0, 8, 9
   9  0, 9
  10  0, 1, 9, 10
  11  -1, 0, 2, 3, 8, 9, 11, 12
  12  0, 3, 9, 12
.
Irregular table T(n, k) begins in balanced ternary:
  n    n-th row
  ---  --------------------------------
    0  0
    1  0, 1
   1T  T, 0, 1T, 10
   10  0, 10
   11  0, 1, 10, 11
  1TT  TT, T0, T, 0, 1TT, 1T0, 10T, 100
  1T0  T0, 0, 1T0, 100
  1T1  T0, T1, 0, 1, 1T0, 1T1, 100, 101
  10T  T, 0, 10T, 100
  100  0, 100
  101  0, 1, 100, 101
  11T  T, 0, 1T, 10, 10T, 100, 11T, 110
  110  0, 10, 100, 110
		

Crossrefs

See A380123 for a similar sequence.

Programs

  • PARI
    row(n) = { my (r = [0], d, t = 1); while (n, d = centerlift(Mod(n, 3)); if (d, r = concat(r, [v + d*t | v <- r]);); n = (n-d)/3; t *= 3;); vecsort(r); }

Formula

T(n, 1) = - A060373(n).
T(n, 2^A005812(n)) = A060372(n).

A134021 Length of n in balanced ternary representation.

Original entry on oeis.org

1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5
Offset: 0

Views

Author

Reinhard Zumkeller, Oct 19 2007

Keywords

Comments

Shifted variant of A064099.

Examples

			100 = 1*3^4+1*3^3-1*3^2+0*3^1+1*3^0: a(100) = |++-0+| = 5.
200 = 1*3^5-1*3^4+1*3^3+1*3^2+1*3^1-1*3^0: a(200) = |+-+++-| = 6.
300 = 1*3^5+1*3^4-1*3^3+0*3^2+1*3^1+0*3^0: a(300) = |++-0+0| = 6.
		

References

  • Donald E. Knuth, The Art of Computer Programming, Addison-Wesley, Reading, MA, Vol. 2, pp. 173-175.

Crossrefs

Programs

  • Mathematica
    a[n_] := Ceiling[Log[3, 2*n+1]]; a[0] = 1; Array[a, 100, 0] (* Amiram Eldar, Apr 03 2025 *)
  • Python
    def a(n):
        if n==0: return 1
        s=0
        x=0
        while n>0:
            x=n%3
            n=n//3
            if x==2:
                x=-1
                n+=1
            s+=1
        return s
    print([a(n) for n in range(101)]) # Indranil Ghosh, Jun 07 2017

Formula

For n > 0: a(n) = ceiling(log(2*n+1)/log(3)).
a(n) = A134022(n) + A134023(n) + A134024(n).
0 <= a(n) - A081604(n) <= 1.
a(A134025(n)) = A081604(A134025(n)); a(A134026(n)) = A081604(A134026(n))+1.
a(A134027(n)) = a(n); a(abs(A134028(n))) <= a(n).
a(n) = A064099(n-1) for n>1.
n = Sum_{k=0..a(n)-1} (A059095(A134421(n)-2-k)*3^k), for n > 0. - Reinhard Zumkeller, Oct 25 2007
a(n) = A005812(n) + A134023(n).

A134023 Number of zeros in balanced ternary representation of n.

Original entry on oeis.org

1, 0, 0, 1, 0, 0, 1, 0, 1, 2, 1, 0, 1, 0, 0, 1, 0, 1, 2, 1, 0, 1, 0, 1, 2, 1, 2, 3, 2, 1, 2, 1, 0, 1, 0, 1, 2, 1, 0, 1, 0, 0, 1, 0, 1, 2, 1, 0, 1, 0, 1, 2, 1, 2, 3, 2, 1, 2, 1, 0, 1, 0, 1, 2, 1, 0, 1, 0, 1, 2, 1, 2, 3, 2, 1, 2, 1, 2, 3, 2, 3, 4, 3, 2, 3, 2, 1, 2, 1, 2, 3, 2, 1, 2, 1, 0, 1, 0, 1, 2, 1, 0, 1, 0, 1
Offset: 0

Views

Author

Reinhard Zumkeller, Oct 19 2007

Keywords

Examples

			100=1*3^4+1*3^3-1*3^2+0*3^1+1*3^0=='++-0+': a(100)=1;
200=1*3^5-1*3^4+1*3^3+1*3^2+1*3^1-1*3^0=='+-+++-': a(200)=0;
300=1*3^5+1*3^4-1*3^3+0*3^2+1*3^1+0*3^0=='++-0+0': a(300)=2.
		

References

  • D. E. Knuth, The Art of Computer Programming, Addison-Wesley, Reading, MA, Vol 2, pp 173-175.

Crossrefs

Programs

  • Mathematica
    Array[Count[If[First@ # == 0, Rest@ #, #], 0] &[Prepend[IntegerDigits[#, 3], 0] //. {a___, b_, 2, c___} :> {a, b + 1, -1, c}] &, 105, 0] (* Michael De Vlieger, Jun 27 2020 *)
  • Python
    def a(n):
        if n==0: return 1
        s=0
        x=0
        while n>0:
            x=n%3
            n=n//3
            if x==2:
                x=-1
                n+=1
            if x==0: s+=1
        return s
    print([a(n) for n in range(101)]) # Indranil Ghosh, Jun 07 2017

Formula

a(n) = A134021(n) - A134022(n) - A134024(n).
a(n) = A134021(n) - A005812(n).

A134022 Number of negative trits in balanced ternary representation of n.

Original entry on oeis.org

0, 0, 1, 0, 0, 2, 1, 1, 1, 0, 0, 1, 0, 0, 3, 2, 2, 2, 1, 1, 2, 1, 1, 2, 1, 1, 1, 0, 0, 1, 0, 0, 2, 1, 1, 1, 0, 0, 1, 0, 0, 4, 3, 3, 3, 2, 2, 3, 2, 2, 3, 2, 2, 2, 1, 1, 2, 1, 1, 3, 2, 2, 2, 1, 1, 2, 1, 1, 3, 2, 2, 2, 1, 1, 2, 1, 1, 2, 1, 1, 1, 0, 0, 1, 0, 0, 2, 1, 1, 1, 0, 0, 1, 0, 0, 3, 2, 2, 2, 1, 1, 2, 1, 1, 2
Offset: 0

Views

Author

Reinhard Zumkeller, Oct 19 2007

Keywords

Examples

			100 = 1*3^4+1*3^3-1*3^2+0*3^1+1*3^0 == '++-0+': a(100) = 1;
200 = 1*3^5-1*3^4+1*3^3+1*3^2+1*3^1-1*3^0 == '+-+++-': a(200) = 2;
300 = 1*3^5+1*3^4-1*3^3+0*3^2+1*3^1+0*3^0 == '++-0+0': a(300) = 1.
		

References

  • D. E. Knuth, The Art of Computer Programming, Addison-Wesley, Reading, MA, Vol 2, pp 173-175.

Crossrefs

Programs

  • Mathematica
    Array[Count[#, -1] &[Prepend[IntegerDigits[#, 3], 0] //. {a___, b_, 2, c___} :> {a, b + 1, -1, c}] &, 105, 0] (* Michael De Vlieger, Jun 27 2020 *)
  • Python
    def a(n):
        s=0
        x=0
        while n>0:
            x=n%3
            n=n//3
            if x==2:
                x=-1
                n+=1
            if x==-1: s+=1
        return s
    print([a(n) for n in range(151)]) # Indranil Ghosh, Jun 07 2017

Formula

a(n) = A134021(n) - A134023(n) - A134024(n).
a(n) = A005812(n) - A134024(n) = A134024(n) - A065363(n).

A134024 Number of positive trits in balanced ternary representation of n.

Original entry on oeis.org

0, 1, 1, 1, 2, 1, 1, 2, 1, 1, 2, 2, 2, 3, 1, 1, 2, 1, 1, 2, 2, 2, 3, 1, 1, 2, 1, 1, 2, 2, 2, 3, 2, 2, 3, 2, 2, 3, 3, 3, 4, 1, 1, 2, 1, 1, 2, 2, 2, 3, 1, 1, 2, 1, 1, 2, 2, 2, 3, 2, 2, 3, 2, 2, 3, 3, 3, 4, 1, 1, 2, 1, 1, 2, 2, 2, 3, 1, 1, 2, 1, 1, 2, 2, 2, 3, 2, 2, 3, 2, 2, 3, 3, 3, 4, 2, 2, 3, 2, 2, 3, 3, 3, 4, 2
Offset: 0

Views

Author

Reinhard Zumkeller, Oct 19 2007

Keywords

Examples

			100=1*3^4+1*3^3-1*3^2+0*3^1+1*3^0=='++-0+': a(100)=3;
200=1*3^5-1*3^4+1*3^3+1*3^2+1*3^1-1*3^0=='+-+++-': a(200)=4;
300=1*3^5+1*3^4-1*3^3+0*3^2+1*3^1+0*3^0=='++-0+0': a(300)=3.
		

References

  • D. E. Knuth, The Art of Computer Programming, Addison-Wesley, Reading, MA, Vol 2, pp 173-175.

Crossrefs

Programs

  • Mathematica
    Array[Count[#, 1] &[Prepend[IntegerDigits[#, 3], 0] //. {a___, b_, 2, c___} :> {a, b + 1, -1, c}] &, 105, 0] (* Michael De Vlieger, Jun 27 2020 *)
  • Python
    def a(n):
        s=0
        x=0
        while n>0:
            x=n%3
            n //= 3
            if x==2:
                x=-1
                n+=1
            if x==1: s+=1
        return s
    print([a(n) for n in range(151)]) # Indranil Ghosh, Jun 07 2017

Formula

a(n) = A134021(n) - A134022(n) - A134023(n);
a(n) > 0 for n > 0.
a(n) = A005812(n) - A134022(n) = A134022(n) + A065363(n).

A379049 a(n) = prime(i)*dp(n,i) + prime(i)*dn(n,i) where dp(n,i) = 1 when the i-th trit of n is 1, dn(n,i) = 1 when the i-th trit of n is T, and dp(n,i) = dn(n,i) = 0 when the i-th trit of n is 0.

Original entry on oeis.org

2, 3, 5, 4, 7, 11, 8, 13, 7, 6, 11, 17, 16, 31, 37, 22, 29, 17, 12, 19, 31, 26, 47, 13, 10, 17, 9, 8, 15, 23, 22, 43, 41, 38, 73, 37, 36, 71, 107, 106, 211, 221, 116, 127, 81, 46, 57, 103, 68, 101, 53, 32, 43, 25, 18, 29, 47, 40, 73, 97, 76, 131, 69, 62, 117
Offset: 0

Views

Author

Lei Zhou, Dec 14 2024

Keywords

Comments

The Balanced Ternary presentation of a number is a series of 1, 0, and T, where T represent -1. For example, 35 = 110T = 1 * 3^3 + 1* 3^2 + 0 * 3 - 1 = 27 + 9 + 0 - 1.
Conjecture: All positive integers greater than 1 appear in this sequence at least once.

Examples

			When n = 0, its BT presentation is 0, thus a(0) = 1 + 1 = 2;
When n = 1, its BT presentation is 1, the first prime is 2, thus a(1) = 2 + 1 = 3;
...
When n = 14, its BT presentation is 1TTT, thus prime 7 appears before the plus sign and primes 5, 3, and 2 appear in the term after the plus sign, a(14) = 7 + 5*3*2 = 37;
...
By the same rule, when n = 64, its BT presentation is 1T101, thus prime 11, 5, 2 appear before the plus sign and prime 7 appears in the term after the plus sign, a(64) = 11*5*2 + 7 = 117.
		

Crossrefs

Programs

  • Mathematica
    BTDigits[m_Integer, g_]:= Module[{n = m, d, sign, t = g}, If[n != 0, If[n > 0, sign = 1, sign = -1; n = -n]; d = Ceiling[Log[3, n]]; If[3^d - n <= ((3^d - 1)/2), d++]; While[Length[t] < d, PrependTo[t, 0]]; t[[Length[t] + 1 - d]] = sign; t = BTDigits[sign*(n - 3^(d - 1)), t]]; t];
    res = {}; Do[BT = BTDigits[i, {0}]; BTl = Length[BT]; f = 1; b = 1; Do[If[BT[[j]] == 1, f = f*Prime[BTl - j + 1]]; If[BT[[j]] == -1, b = b*Prime[BTl - j + 1]], {j, 1, BTl}];  d = f + b; AppendTo[res, d], {i, 0, 64}]; res
  • Python
    from sympy import prime
    def A140267(n): # see A140267
        return
    def A379049(n):
        x,y,z = 1,1,str(A140267(n))[::-1]
        for i in range(len(z)):
            if z[i] == "1":
                x *= prime(i+1)
            if z[i] == "2":
                y *= prime(i+1)
        return x+y # John Tyler Rascoe, Feb 27 2025

A343602 For any positive number n, the balanced ternary representation of a(n) is obtained by left-rotating the balanced ternary representation of n until a nonzero digit appears again as the leftmost digit; a(0) = 0.

Original entry on oeis.org

0, 1, -2, 3, 4, -11, -8, -5, -6, 9, 12, 7, 10, 13, -38, -35, -32, -29, -26, -23, -20, -17, -14, -33, -24, -15, -18, 27, 36, 21, 30, 39, 16, 19, 22, 25, 28, 31, 34, 37, 40, -119, -116, -113, -110, -107, -104, -101, -98, -95, -92, -89, -86, -83, -80, -77, -74
Offset: 0

Views

Author

Rémy Sigrist, Apr 21 2021

Keywords

Comments

This sequence can be extended to negative indexes by setting a(-n) = -a(n) for any n > 0. We then obtain a permutation of the integers (Z) with inverse A343601 (after a similar extension to negative indexes).

Examples

			The first terms, in base 10 and in balanced ternary (where T denotes the digit -1), are:
  n   a(n)  bter(n)  bter(a(n))
  --  ----  -------  ----------
   0     0        0           0
   1     1        1           1
   2    -2       1T          T1
   3     3       10          10
   4     4       11          11
   5   -11      1TT         TT1
   6    -8      1T0         T01
   7    -5      1T1         T11
   8    -6      10T         T10
   9     9      100         100
  10    12      101         110
  11     7      11T         1T1
  12    10      110         101
  13    13      111         111
  14   -38     1TTT        TTT1
  15   -35     1TT0        TT01
		

Crossrefs

Cf. A005812, A065363, A134021, A139708 (binary variant), A343600 (ternary variant), A343603 (inverse).

Programs

  • PARI
    a(n) = { my (d = [], t); while (n, d = concat(t = centerlift(Mod(n,3)), d); n = (n-t)\3); for (k=2, #d, if (d[k], return (fromdigits(concat(d[k..#d], d[1..k-1]), 3)))); return (fromdigits(d, 3)) }

Formula

A065363(a(n)) = A065363(n).
A134021(a(n)) = A134021(n).
a^k(n) = n for k = A005812(n) (where a^k denotes the k-th iterate of a).

A343603 For any positive number n, the balanced ternary representation of a(n) is obtained by right-rotating the balanced ternary representation of n until a nonzero digit appears again as the leftmost digit; a(0) = 0.

Original entry on oeis.org

0, 1, -2, 3, 4, -7, -8, 11, -6, 9, 12, -5, 10, 13, -22, -25, 32, -21, -26, 33, -20, 29, 34, -19, -24, 35, -18, 27, 36, -17, 30, 37, -16, -23, 38, -15, 28, 39, -14, 31, 40, -67, -76, 95, -66, -79, 96, -65, 86, 97, -64, -75, 98, -63, -80, 99, -62, 87, 100, -61
Offset: 0

Views

Author

Rémy Sigrist, Apr 21 2021

Keywords

Comments

This sequence can be extended to negative indexes by setting a(-n) = -a(n) for any n > 0. We then obtain a permutation of the integers (Z) with inverse A343602 (after a similar extension to negative indexes).

Examples

			The first terms, in base 10 and in balanced ternary (where T denotes the digit -1), are:
  n   a(n)  bter(n)  bter(a(n))
  --  ----  -------  ----------
   0     0        0           0
   1     1        1           1
   2    -2       1T          T1
   3     3       10          10
   4     4       11          11
   5    -7      1TT         T1T
   6    -8      1T0         T01
   7    11      1T1         11T
   8    -6      10T         T10
   9     9      100         100
  10    12      101         110
  11    -5      11T         T11
  12    10      110         101
  13    13      111         111
  14   -22     1TTT        T1TT
  15   -25     1TT0        T01T
		

Crossrefs

Cf. A005812, A065363, A134021, A139706 (binary variant), A343601 (ternary variant), A343602 (inverse).

Programs

  • PARI
    a(n) = { my (d = [], t); while (n, d = concat(t = centerlift(Mod(n,3)), d); n = (n-t)\3); forstep (k=#d, 1, -1, if (d[k], return (fromdigits(concat(d[k..#d], d[1..k-1]), 3)))); return (fromdigits(d, 3)) }

Formula

A065363(a(n)) = A065363(n).
A134021(a(n)) = A134021(n).
a^k(n) = n for k = A005812(n) (where a^k denotes the k-th iterate of a).

A379260 Index of first appearance of n in sequence A379049.

Original entry on oeis.org

0, 1, 3, 2, 9, 4, 6, 26, 24, 5, 18, 7, 78, 28, 12, 11, 54, 19, 216, 71, 15, 29, 162, 53, 21, 73, 231, 16, 486, 13, 51, 217, 84, 83, 36, 14, 33, 647, 57, 32, 4374, 31, 237, 649, 45, 22, 207, 236, 165, 1945, 693, 50, 2151, 212, 90, 46, 87, 160, 39366, 86, 63
Offset: 2

Views

Author

Lei Zhou, Dec 19 2024

Keywords

Comments

a(n) is the smallest integer that makes A379049(a(n)) = n.
Conjecture: a(n) is defined for all integer n > 1.

Examples

			For n = 2, A379049(0) = 1 + 1 = 2.  Thus a(2) = 0;
For n = 3, A379049(1) = 2 + 1 = 3, since 1's balanced ternary representation is 1.  Thus a(3) = 1;
For n = 4, A379049(3) = 3 + 1 = 4, since 3's balanced ternary representation is 10.  Thus a(4) = 3;
...
For n = 60, A379049(39366) = 31 + 29 = 60, since 39366's balanced ternary representation is 1T000000000, where the 11's digit is 1 represents the 11's prime 31 in the term before the plus sign, and the 10's digit is T representing the 10's prime 29 in the term after the plus sign. And evaluation of A379049 found no number i smaller than 39366 can make A379049(i) = 60.  Thus a(60) = 39366.
		

Crossrefs

Programs

  • Mathematica
    BTDigits[m_Integer, g_] :=  Module[{n = m, d, sign, t = g}, If[n != 0, If[n > 0, sign = 1, sign = -1; n = -n]; d = Ceiling[Log[3, n]]; If[3^d - n <= ((3^d - 1)/2), d++];    While[Length[t] < d, PrependTo[t, 0]]; t[[Length[t] + 1 - d]] = sign; t = BTDigits[sign*(n - 3^(d - 1)), t]]; t];
    goal = 62; res = {}; ct = 1;
    Do[AppendTo[res, 0], {i, 2, goal}]; i = -1; While[ct < goal, i++; BT = BTDigits[i, {0}]; BTl = Length[BT]; f = 1; b = 1;  Do[If[BT[[j]] == 1, f = f*Prime[BTl - j + 1]];   If[BT[[j]] == -1, b = b*Prime[BTl - j + 1]], {j, 1, BTl}]; d = f + b; If[(d <= goal) && (res[[d - 1]] == 0), res[[d - 1]] = i; ct++]];
    res
Showing 1-9 of 9 results.