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-10 of 11 results. Next

A257869 Nonnegative integers with an equal number of occurrences of all trits in balanced ternary representation.

Original entry on oeis.org

6, 8, 136, 138, 144, 154, 156, 160, 164, 168, 170, 180, 186, 188, 208, 210, 214, 218, 222, 224, 232, 236, 248, 258, 260, 266, 288, 294, 296, 312, 314, 320, 3406, 3412, 3414, 3430, 3432, 3438, 3484, 3486, 3492, 3510, 3568, 3574, 3576, 3592, 3594, 3600, 3622
Offset: 1

Views

Author

Alois P. Heinz, May 11 2015

Keywords

Examples

			6 = 1L0_bal3, 8 = 10L_bal3, 136 = 1LL001_bal3, 138 = 1LL010_bal3, 144 = 1LL100_bal3, where L represents (-1).
		

Crossrefs

Subsequence of A174658.

Programs

  • Maple
    p:= proc(n) local d, m, r; m:=n; r:=0;
          while m>0 do
            d:= irem(m, 3, 'm');
            if d=2 then m:=m+1 fi;
            r:= r+x^d
          od;
          simplify(r/(1+x+x^2))::integer
        end:
    a:= proc(n) option remember; local k;
          for k from 1+`if`(n=1, 0, a(n-1)) by 1
          while not p(k) do od; k
        end:
    seq(a(n), n=1..70);
  • Python
    def a(n):
        s=[]
        x=0
        while n>0:
            x=n%3
            n//=3
            if x==2:
                x=-1
                n+=1
            s.append(x)
        return s
    print([n for n in range(1, 5001) if a(n).count(1)==a(n).count(-1) and a(n).count(-1)==a(n).count(0)]) # Indranil Ghosh, Jun 07 2017

A174657 Balanced ternary numbers with more negative trits than positive trits.

Original entry on oeis.org

5, 14, 15, 17, 23, 41, 42, 43, 44, 45, 47, 50, 51, 53, 59, 68, 69, 71, 77, 95, 122, 123, 124, 125, 126, 127, 128, 129, 131, 132, 133, 134, 135, 137, 140, 141, 143, 149, 150, 151, 152, 153, 155, 158, 159, 161, 167, 176, 177, 179, 185, 203, 204, 205, 206, 207, 209
Offset: 1

Views

Author

Daniel Forgues, Mar 26 2010

Keywords

Comments

Numbers for which the sum of trits is negative.

Crossrefs

Programs

  • Mathematica
    (* First run the program for A065363 to define balTernDigits *) Select[Range[210], Count[balTernDigits[#], -1] > Count[balTernDigits[#], 1] &] (* Alonso del Arte, Feb 26 2011 *)
  • Python
    def a(n):
        s=0
        x=0
        while n>0:
            x=n%3
            n//=3
            if x==2:
                x=-1
                n+=1
            s+=x
        return s
    print([n for n in range(301) if a(n)<0]) # Indranil Ghosh, Jun 07 2017

A174659 Numbers whose balanced ternary representation has more positive trits than negative trits.

Original entry on oeis.org

1, 3, 4, 7, 9, 10, 11, 12, 13, 19, 21, 22, 25, 27, 28, 29, 30, 31, 33, 34, 35, 36, 37, 38, 39, 40, 49, 55, 57, 58, 61, 63, 64, 65, 66, 67, 73, 75, 76, 79, 81, 82, 83, 84, 85, 87, 88, 89, 90, 91, 92, 93, 94, 97, 99, 100, 101, 102, 103, 105, 106, 107, 108, 109, 110, 111, 112
Offset: 1

Views

Author

Daniel Forgues, Mar 26 2010

Keywords

Comments

Numbers for which the sum of trits is positive.

Crossrefs

Programs

  • Mathematica
    (* First run the program for A065363 to define balTernDigits *) Select[Range[210], Count[balTernDigits[#], -1] < Count[balTernDigits[#], 1] &] (* Alonso del Arte, Feb 26 2011 *)
  • Python
    def a(n):
        s=0
        x=0
        while n>0:
            x=n%3
            n//=3
            if x==2:
                x=-1
                n+=1
            s+=x
        return s
    print([n for n in range(301) if a(n)>0]) # Indranil Ghosh, Jun 07 2017

Formula

a(n) < 2n. - Yifan Xie, Dec 24 2024

A350229 a(n) is the sum of n and the balanced ternary digits in n.

Original entry on oeis.org

0, 2, 2, 4, 6, 4, 6, 8, 8, 10, 12, 12, 14, 16, 12, 14, 16, 16, 18, 20, 20, 22, 24, 22, 24, 26, 26, 28, 30, 30, 32, 34, 32, 34, 36, 36, 38, 40, 40, 42, 44, 38, 40, 42, 42, 44, 46, 46, 48, 50, 48, 50, 52, 52, 54, 56, 56, 58, 60, 58, 60, 62, 62, 64, 66, 66, 68
Offset: 0

Views

Author

Rémy Sigrist, Jan 09 2022

Keywords

Comments

The image of this sequence is the set of nonnegative even numbers (A005843).

Examples

			For n = 42:
- the balanced ternary representation of 42 is "1TTT0",
- so a(42) = 42 + 1 - 1 - 1 - 1 + 0 = 40.
		

Crossrefs

See A062028, A092391, A230641 for similar sequences.
Cf. A005843, A065363, A174658 (fixed points).

Programs

  • Mathematica
    Array[# + Total[If[First@ # == 0, Rest@ #, #] &[Prepend[IntegerDigits[#, 3], 0] //. {x___, y_, k_ /; k > 1, z___} :> {x, y + 1, k - 3, z}]] &, 70, 0] (* Michael De Vlieger, Jan 15 2022 *)
  • PARI
    a(n) = my (v=n, d); while (n, n=(n-d=[0,1,-1][1+n%3])/3; v+=d); v

Formula

a(n) = n + A065363(n).
a(n) = n iff n belongs to A174658.

A343604 a(n) is the least number > n with the same sum of balanced ternary digits as n.

Original entry on oeis.org

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

Views

Author

Rémy Sigrist, Apr 22 2021

Keywords

Comments

This sequence can be extended to negative indexes by setting a(-n) = -A343605(n) for any n > 0.

Examples

			The first terms, in base 10 and in balanced ternary (where T denotes the digit -1), alongside A065363(n), are:
  n   a(n)  bter(n)  bter(a(n))  A065363(n)
  --  ----  -------  ----------  ----------
   0     2        0          1T           0
   1     3        1          10           1
   2     6       1T         1T0           0
   3     7       10         1T1           1
   4    10       11         101           2
   5    15      1TT        1TT0          -1
   6     8      1T0         10T           0
   7     9      1T1         100           1
   8    16      10T        1TT1           0
   9    11      100         11T           1
  10    12      101         110           2
  11    19      11T        1T01           1
  12    22      110        1T11           2
		

Crossrefs

Programs

  • PARI
    A065363(n) = { my (v=0, d); while (n, v+=d=centerlift(Mod(n,3)); n=(n-d)\3); v }
    a(n) = my (s=A065363(n)); for (k=n+1, oo, if (s==A065363(k), return (k)))

Formula

a(9*n) = 9*n + 2.
a(A174658(n)) = A174658(n+1).

A343605 a(n) is the greatest number < n with the same sum of balanced ternary digits as n.

Original entry on oeis.org

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

Views

Author

Rémy Sigrist, Apr 22 2021

Keywords

Comments

This sequence can be extended to negative indexes by setting a(-n) = -A343604(n) for any n > 0.

Examples

			The first terms, in base 10 and in balanced ternary (where T denotes the digit -1), alongside A065363(n), are:
  n   a(n)  bter(n)  bter(a(n))  A065363(n)
  --  ----  -------  ----------  ----------
   0    -2        0          T1           0
   1    -5        1         T11           1
   2     0       1T           0           0
   3     1       10           1           1
   4   -14       11        T111           2
   5    -1      1TT           T          -1
   6     2      1T0          1T           0
   7     3      1T1          10           1
   8     6      10T         1T0           0
   9     7      100         1T1           1
  10     4      101          11           2
  11     9      11T         100           1
  12    10      110         101           2
		

Crossrefs

Programs

  • PARI
    A065363(n) = { my (v=0, d); while (n, v+=d=centerlift(Mod(n,3)); n=(n-d)\3); v }
    a(n) = my (s=A065363(n)); forstep (k=n-1, -oo, -1, if (s==A065363(k), return (k)))

Formula

a(9*n) = 9*n - 2.
a(A174658(n+1)) = A174658(n) for any n > 0.
a(n) <= 0 iff n belongs to A003462 or to A007051.
a(A003462(k)) = -A007051(k + 1) for any k >= 0.
a(A007051(k)) = -A003462(k - 1) for any k > 0.

A355639 a(n) is the least k > 0 such that the balanced ternary expansion of k*n contains as many negative trits as positive trits.

Original entry on oeis.org

1, 2, 1, 2, 2, 4, 1, 8, 1, 2, 2, 14, 2, 2, 4, 4, 1, 8, 1, 14, 1, 8, 7, 2, 1, 16, 1, 2, 2, 8, 2, 2, 1, 14, 4, 2, 2, 2, 7, 2, 2, 4, 4, 2, 10, 4, 1, 4, 1, 2, 8, 8, 1, 8, 1, 8, 1, 14, 4, 4, 1, 8, 1, 8, 5, 2, 7, 14, 2, 2, 1, 2, 1, 2, 1, 16, 7, 2, 1, 8, 1, 2, 2, 8
Offset: 0

Views

Author

Rémy Sigrist, Jul 11 2022

Keywords

Comments

The sequence is well defined: for n > 0, by the pigeonhole principle, there are necessarily two distinct integers i and j (say with i > j) such that 3^i == 3^j (mod n); the value 3^i - 3^j is a positive multiple of n containing exactly one positive trit and one negative trit, so a(n) <= (3^i - 3^j) / n.

Examples

			For n = 5:
- the first multiple of 5 (alongside their balanced ternary expansions) are:
      k  k*5  bter(k*5)  #1  #T
      -  ---  ---------  --  --
      1    5        1TT   1   2
      2   10        101   2   0
      3   15       1TT0   1   2
      4   20       1T1T   2   2
- negative and positive trits are first balanced for k = 4,
- so a(5) = 4.
		

Crossrefs

See A351599 for a similar sequence.

Programs

  • PARI
    a(n) = { for (k=1, oo, my (m=k*n, s=0, d); while (m, m=(m-d=[0,1,-1][1+m%3])/3; s+=d); if (s==0, return (k))) }

Formula

a(n) = 1 iff n belongs to A174658.

A283800 Numbers such that the sum of trits of its balanced ternary representation is 1 or -1.

Original entry on oeis.org

1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25, 27, 29, 33, 35, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 69, 71, 73, 75, 77, 79, 81, 83, 87, 89, 95, 97, 99, 101, 105, 107, 113, 127, 129, 133, 135, 137, 139, 141, 143, 145, 147, 151, 153, 155, 157, 159, 161
Offset: 1

Views

Author

Lei Zhou, Mar 16 2017

Keywords

Examples

			3 = 10 in balanced ternary (bt) notation, 1+0 = 1, so 3 is in the list;
...
11 = 11T in bt notation, 1+1+T = 1, here T represent -1, so 11 is in the list;
13 = 111 in bt notation, 1+1+1 = 3, so 13 is NOT in the list.
		

Crossrefs

Programs

  • Mathematica
    BTDigits[m_Integer,
       g_] :=(*This is to determine digits of a number in balanced \
    ternary notation.*)
      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];
    n = 0; Table[While[n++; g = {}; bt = BTDigits[n, g]; s = Total[bt];
      Abs[s] != 1]; n, {i, 1, 61}]

A355640 a(0) = 0, and for any n > 0, a(n) is the least positive multiple of n whose balanced ternary expansion contains as many negative trits as positive trits.

Original entry on oeis.org

0, 2, 2, 6, 8, 20, 6, 56, 8, 18, 20, 154, 24, 26, 56, 60, 16, 136, 18, 266, 20, 168, 154, 46, 24, 400, 26, 54, 56, 232, 60, 62, 32, 462, 136, 70, 72, 74, 266, 78, 80, 164, 168, 86, 440, 180, 46, 188, 48, 98, 400, 408, 52, 424, 54, 440, 56, 798, 232, 236, 60
Offset: 0

Views

Author

Rémy Sigrist, Jul 11 2022

Keywords

Comments

A174658 corresponds to fixed points.

Examples

			For n = 5:
- the first multiple of 5 (alongside their balanced ternary expansions) are:
      k  k*5  bter(k*5)  #1  #T
      -  ---  ---------  --  --
      1    5        1TT   1   2
      2   10        101   2   0
      3   15       1TT0   1   2
      4   20       1T1T   2   2
- negative and positive trits are first balanced for k = 4,
- so a(5) = 4*5 = 20.
		

Crossrefs

See A143146 for a similar sequence.
Cf. A065363, A174658 (fixed points), A355639.

Programs

  • PARI
    a(n) = { for (k=1, oo, my (m=k*n, s=0, d); while (m, m=(m-d=[0, 1, -1][1+m%3])/3; s+=d); if (s==0, return (k*n))) }

Formula

a(n) = n * A355639(n).

A355642 Lexicographically earliest sequence of distinct nonnegative integers such that for any n >= 0, the balanced ternary expansion of n * a(n) contains as many negative trits as positive trits.

Original entry on oeis.org

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

Views

Author

Rémy Sigrist, Jul 11 2022

Keywords

Comments

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

Examples

			The first terms, alongside the balanced ternary expansion of n * a(n), are:
  n   a(n)  bter(n*a(n))
  --  ----  ------------
   0     0             0
   1     2            1T
   2     1            1T
   3     6          1T00
   4     4          1TT1
   5    12         1T1T0
   6     3          1T00
   7     8         1T01T
   8     7         1T01T
   9    16        1TT100
  10    13        1TTT11
  11    14        1T0T01
  12     5         1T1T0
		

Crossrefs

See A306993 for a similar sequence.

Programs

  • PARI
    See Links section.
Showing 1-10 of 11 results. Next