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 13 results. Next

A014190 Palindromes in base 3 (written in base 10).

Original entry on oeis.org

0, 1, 2, 4, 8, 10, 13, 16, 20, 23, 26, 28, 40, 52, 56, 68, 80, 82, 91, 100, 112, 121, 130, 142, 151, 160, 164, 173, 182, 194, 203, 212, 224, 233, 242, 244, 280, 316, 328, 364, 400, 412, 448, 484, 488, 524, 560, 572, 608, 644, 656, 692, 728, 730, 757
Offset: 1

Views

Author

Keywords

Comments

Rajasekaran, Shallit, & Smith prove that this sequence is an additive basis of order (exactly) 3. - Charles R Greathouse IV, May 03 2020

Crossrefs

Cf. A007089, A118594, A134027, A330312 (first differences).
Palindromes in bases 2 through 10: A006995, A014190, A014192, A029952, A029953, A029954, A029803, A029955, A002113.

Programs

  • Magma
    [n: n in [0..800] | Intseq(n, 3) eq Reverse(Intseq(n, 3))]; // Vincenzo Librandi, Sep 09 2015
    
  • Maple
    isA014190 := proc(n)
        local L;
        L := convert(n,base,3) ;
        ListTools[Reverse](L) = L ;
    end proc:
    for n from 0 to 500 do
        if isA014190(n) then
            printf("%d,",n) ;
        end if;
    end do: # R. J. Mathar, Jul 07 2015
  • Mathematica
    f[n_,b_] := Module[{i=IntegerDigits[n,b]}, i==Reverse[i]]; lst={}; Do[If[f[n,3], AppendTo[lst,n]], {n,1000}]; lst (* Vladimir Joseph Stephan Orlovsky, Jul 08 2009 *)
  • PARI
    ispal(n,b=3)=my(d=digits(n,b)); d==Vecrev(d) \\ Charles R Greathouse IV, May 03 2020
    
  • Python
    from gmpy2 import digits
    def A014190(n):
        if n == 1: return 0
        y = 3*(x:=3**(len(digits(n>>1,3))-1))
        return int((c:=n-x)*x+int(digits(c,3)[-2::-1]or'0',3) if nChai Wah Wu, Jun 13 2024
  • Sage
    [n for n in (0..757) if Word(n.digits(3)).is_palindrome()] # Peter Luschny, Sep 13 2018
    

Formula

Sum_{n>=2} 1/a(n) = 2.61676111... (Phunphayap and Pongsriiam, 2019). - Amiram Eldar, Oct 17 2020

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).

A134028 Reversal of n in balanced ternary representation.

Original entry on oeis.org

0, 1, -2, 1, 4, -11, -2, 7, -8, 1, 10, -5, 4, 13, -38, -11, 16, -29, -2, 25, -20, 7, 34, -35, -8, 19, -26, 1, 28, -17, 10, 37, -32, -5, 22, -23, 4, 31, -14, 13, 40, -119, -38, 43, -92, -11, 70, -65, 16, 97, -110, -29, 52, -83, -2, 79, -56, 25, 106, -101, -20, 61, -74, 7, 88, -47, 34, 115, -116, -35, 46, -89, -8, 73, -62, 19, 100
Offset: 0

Views

Author

Reinhard Zumkeller, Oct 19 2007

Keywords

Comments

As the graph demonstrates, the sequence makes large negative steps at terms (3^i+1)/2. These steps divide the graph into conspicuous blocks. - N. J. A. Sloane, Jul 03 2016

Examples

			20 = 1*3^3 - 1*3^2 + 1*3^1 - 1*3^0 == '+-+-'
=> a(20) = -1*3^3 + 1*3^2 - 1*3^1 + 1*3^0 = -20;
21 = 1*3^3 - 1*3^2 + 1*3^1 + 0*3^0 == '+-+0'
=> a(21) = 0*3^3 + 1*3^2 - 1*3^1 + 1*3^0 = 7;
22 = 1*3^3 - 1*3^2 + 1*3^1 + 1*3^0 == '+-++'
=> a(22) = 1*3^3 + 1*3^2 - 1*3^1 + 1*3^0 = 34;
23 = 1*3^3 + 0*3^2 - 1*3^1 - 1*3^0 == '+0--'
=> a(23) = -1*3^3 - 1*3^2 + 0*3^1 + 1*3^0 = -35;
24 = 1*3^3 + 0*3^2 - 1*3^1 + 0*3^0 == '+0-0'
=> a(24) = 0*3^3 - 1*3^2 + 0*3^1 + 1*3^0 = -8;
25 = 1*3^3 + 0*3^2 - 1*3^1 + 1*3^0 == '+0-+'
=> a(25) = 1*3^3 - 1*3^2 + 0*3^1 + 1*3^0 = 19.
		

References

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

Crossrefs

Cf. A117966 (balanced ternary representation), A030102, A134021, A274107.
A134027 gives the numbers whose balanced ternary representation is palindromic.

Programs

  • Python
    def a(n):
        if n==0: return 0
        s=[]
        x=0
        while n>0:
            x=n%3
            n=n//3
            if x==2:
                x=-1
                n+=1
            s.append(x)
        l=s[::-1]
        return sum(l[i]*3**i for i in range(len(l)))
    print([a(n) for n in range(101)]) # Indranil Ghosh, Jun 10 2017

Formula

a(A134027(n)) = A134027(n);
A134021(ABS(a(n))) <= A134021(n).

A233010 In balanced ternary notation, either a palindrome or becomes a palindrome if trailing 0's are omitted.

Original entry on oeis.org

0, 1, 3, 4, 7, 9, 10, 12, 13, 16, 21, 27, 28, 30, 36, 39, 40, 43, 48, 52, 61, 63, 73, 81, 82, 84, 90, 91, 103, 108, 112, 117, 120, 121, 124, 129, 144, 156, 160, 183, 189, 196, 208, 219, 243, 244, 246, 252, 270, 273, 280, 292, 309, 324, 328, 336, 351, 360, 363
Offset: 1

Views

Author

Lei Zhou, Dec 13 2013

Keywords

Comments

Symmetric strings of -1, 0, and 1, including as many leading as trailing zeros.

Examples

			10 is included since in balanced ternary notation 10 = (101)_bt is a palindrome;
144 is included since 144 = (1TT100)_bt, where we use T to represent -1.  When trailing zeros removed, 1TT1 is a palindrome.
		

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];
    BTpaleQ[n_Integer] := Module[{t, trim = n/3^IntegerExponent[n, 3]},
      t = BTDigits[trim, {0}]; t == Reverse[t]];
    Select[Range[0, 363], BTpaleQ[#] &]

A233571 In balanced ternary notation, reverse digits of a(n) equals to -a(n).

Original entry on oeis.org

0, 2, 8, 20, 26, 32, 56, 80, 104, 146, 164, 182, 224, 242, 260, 302, 320, 338, 416, 488, 560, 656, 728, 800, 896, 968, 1040, 1172, 1226, 1280, 1406, 1460, 1514, 1640, 1694, 1748, 1898, 1952, 2006, 2132, 2186, 2240, 2366, 2420, 2474, 2624, 2678, 2732, 2858
Offset: 1

Views

Author

Lei Zhou, Dec 13 2013

Keywords

Examples

			In balanced ternary notation, 8=(10T)_bt, where we use T to represent -1.  Reverse digits of (10T)_bt is (T01)_bt = -8. So 8 is in this sequence.
Similarly, 2240 = (1001T00T)_bt, whose reverse digits is (T00T1001)_bt = -2240.  So 2240 is in this sequence.
		

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];
    ct = 1; n = 0; m = 0; dg = 0; switch = 1; res = {0}; While[ct < 50, n++;
      bits = BTDigits[n, {0}]; If[lb = Length[bits]; lb > dg,
      If[switch == 0, n = m; switch = 1; OK = 0, dg = lb; m = n - 1;
       switch = 0; OK = 1], OK = 1];  If[OK == 1, rbt = -Reverse[bits];
      If[switch == 1, nb = Join[bits, {0}], nb = bits];
      nb = Join[nb, rbt]; nb = Reverse[nb]; data = 0;
      Do[data = data + 3^(i - 1)*nb[[i]], {i, 1, Length[nb]}]; ct++;
      AppendTo[res, data]]]; res

A233572 In balanced ternary notation, if prepending same numbers of zeros, reverse digits of a(n) equals to -a(n).

Original entry on oeis.org

0, 2, 6, 8, 18, 20, 24, 26, 32, 54, 56, 60, 72, 78, 80, 96, 104, 146, 162, 164, 168, 180, 182, 216, 224, 234, 240, 242, 260, 288, 302, 312, 320, 338, 416, 438, 486, 488, 492, 504, 540, 546, 560, 648, 656, 672, 702, 720, 726, 728, 780, 800, 864, 896, 906, 936
Offset: 1

Views

Author

Lei Zhou, Dec 13 2013

Keywords

Comments

A233571 is a subset of this sequence.

Examples

			In balanced ternary notation, 18 = (1T00)_bt, where we use T to represent -1.  Patching two zeros before it, (1T00)_bt=(001T00)_bt.  The reverse digits of (001T00)_bt is (00T100)_bt = -18.  So 18 is in this sequence.
		

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];
    BTrteQ[n_Integer] :=
    Module[{t, trim = n/3^IntegerExponent[n, 3]},
      t = BTDigits[trim, {0}]; DeleteDuplicates[t + Reverse[t]] == {0}];
    sb = Select[Range[0, 950], BTrteQ[#] &]

A351702 In the balanced ternary representation of n, reverse the order of digits other than the most significant.

Original entry on oeis.org

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

Views

Author

Kevin Ryde, Feb 19 2022

Keywords

Comments

Self-inverse permutation with swaps confined to terms of a given digit length (A134021) so within blocks n = (3^k+1)/2 .. (3^(k+1)-1)/2.
Can extend to negative n by a(-n) = -a(n).
A072998 is balanced ternary coded in decimal digits so that reversal except first digit of A072998(n) is at A072998(a(n)). Similarly its ternary equivalent A157671, and also A132141 ternary starting with 1.
These sequences all have a fixed initial digit followed by all ternary strings which is the reversed part. A007932 is such strings as decimal digits 1,2,3 but it omits the empty string so the whole reversal of A007932(n) is at A007932(a(n+1)-1).
Fixed points a(n) = n are where n in balanced ternary is a palindrome apart from its initial 1. These are the full balanced ternary palindromes with their least significant 1 removed, so all n = (A134027(m)-1)/3 for m>=2.

Examples

			n    = 224 = balanced ternary 1,  0, -1, 1,  0, -1
                      reverse     ^^^^^^^^^^^^^^^^
a(n) = 168 = balanced ternary 1, -1,  0, 1, -1,  0
		

Crossrefs

Cf. A059095 (balanced ternary), A134028 (full reverse), A134027 (palindromes).
In other bases: A059893 (binary), A343150 (Zeckendorf), A343152 (lazy Fibonacci).

Programs

  • PARI
    a(n) = if(n==0,0, my(k=if(n,logint(n<<1,3)), s=(3^k+1)>>1); s + fromdigits(Vec(Vecrev(digits(n-s,3)),k),3));

A224502 Prime numbers (together with one) whose representation in balanced ternary are palindromes.

Original entry on oeis.org

1, 7, 13, 43, 61, 73, 103, 367, 421, 457, 547, 601, 613, 757, 859, 1039, 1093, 3823, 4021, 4561, 4723, 4759, 5743, 6211, 6373, 6481, 6949, 7219, 7489, 7933, 8563, 8941, 9103, 9679, 29527, 30013, 31147, 31741, 33037, 35251, 36061, 36097, 36583, 37717, 39607, 41011, 42667, 43963, 44773, 45691, 47581, 49201
Offset: 1

Views

Author

Malachi de Ælfweald, Apr 08 2013

Keywords

Comments

Intersection of A006005 and A134027.

Examples

			For n=5, a(5)=61 and in balanced ternary notation is 1ī1ī1.
		

Programs

  • PARI
    bt(k,n)={
        sum(i=0,(n-1)\2,
            my(t=k%3-1);
            k\=3;
            n--;
            if(n==i,3^n,3^i+3^n)*t
        )
    };
    do(N)={
        my(v=List([1]),t);
        for(n=1,N,
            forstep(k=2,3^((n+1)\2)-1,3,
                t=bt(k,n);
                if(isprime(t),listput(v,t))
            )
        );
        vecsort(Vec(v))
    }; \\ Charles R Greathouse IV, Apr 08 2013

A233573 Number of ways n can be partitioned as A233010(i)+A233572(j), where i,j >= 1.

Original entry on oeis.org

1, 1, 1, 2, 1, 1, 2, 2, 1, 4, 2, 2, 3, 2, 1, 3, 2, 1, 4, 2, 2, 4, 2, 2, 3, 2, 1, 6, 3, 4, 5, 2, 3, 5, 3, 3, 7, 1, 3, 4, 2, 3, 4, 1, 2, 5, 2, 3, 5, 1, 2, 2, 2, 2, 6, 1, 4, 3, 3, 3, 6, 4, 2, 7, 3, 3, 4, 4, 3, 5, 3, 2, 6, 3, 1, 4, 3, 1, 2, 4, 2, 9, 4, 4, 7, 3, 2
Offset: 0

Views

Author

Lei Zhou, Dec 13 2013

Keywords

Comments

Number in sequence A233010 takes palindrome form when written in balanced ternary notation and left patch same number of zeros as number of trailing zeros, which means that if we slice the balanced ternary notation number with left zero padding in the middle, the left part is a mirrored image of the right part. This is a feature like an even function.
Number in sequence A233571 takes "reversed palindrome form" when written in balanced ternary notation and left patch same number of zeros as number of trailing zeros, which means that if we slice the balanced ternary notation number with left zero padding in the middle, the left part is a mirrored image of the right part with sign changes. This is a feature like an odd function.
This sequence gives the number of possibilities of such partitions.
In the first 10000 terms, 152 zeros found.

Examples

			0=0+0=A233010(1)+A233572(1). This is the only valid partition by definition. So a(0)=1.
3=3+0=A233010(3)+A233572(1), as well 3=1+2=A233010(2)+A233572(2).
  Two valid partitions found. So a(3)=2.
9=9+0=7+2=3+6=1+8, four valid partitions found. So a(9)=4.
		

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];
    BTpaleQ[n_Integer] :=
    (*This is to query if a number is an element of sequence A233010.*)
    Module[{t, trim = n/3^IntegerExponent[n, 3]},
      t = BTDigits[trim, {0}]; t == Reverse[t]];
    BTrteQ[n_Integer] :=
    (*This is to query if a number is an element of sequence A233572.*)
    Module[{t, trim = n/3^IntegerExponent[n, 3]},
      t = BTDigits[trim, {0}]; DeleteDuplicates[t + Reverse[t]] == {0}];
    sa = Select[Range[0, 11000], BTpaleQ[#] &];
    (*This is to generate a limited list of A233010.*)
    sb = Select[Range[0, 11000], BTrteQ[#] &];
    (*This is to generate a limited list of A233572.*)
    range = 86; Table[ct = 0; i1 = 0;
    While[i1++; sa[[i1]] <= n, i2 = 0;
      While[i2++; (sa[[i1]] + sb[[i2]]) <= n,
       If[(sa[[i1]] + sb[[i2]]) == n, ct++]]]; ct, {n, 0, range}]

A354885 Numbers that are palindromes in both ternary and balanced ternary representations.

Original entry on oeis.org

0, 1, 4, 10, 13, 16, 28, 40, 52, 82, 91, 112, 121, 160, 244, 280, 328, 364, 484, 730, 757, 820, 847, 976, 1003, 1066, 1093, 1312, 1456, 2188, 2296, 2440, 2548, 2920, 3028, 3172, 3280, 3904, 4372, 6562, 6643, 6832, 6913, 7300, 7381, 7570, 7651, 8752, 8833, 9022
Offset: 1

Views

Author

Amiram Eldar, Jun 10 2022

Keywords

Examples

			4 is a term since its ternary and balanced ternary representation are both 11 which is a palindrome.
16 is a term since its ternary representation is 121 and its balanced ternary representation (with 2 standing for the -1 digit) is 1221, and both are palindromes.
		

Crossrefs

Intersection of A014190 and A134027.
Subsequences: A003462, A034472 \ {2}, A354886.

Programs

  • Mathematica
    Select[Range[0, 10^4], PalindromeQ[IntegerDigits[#, 3]] && PalindromeQ @ balTernDigits[#] &] (* using balTernDigits by Robert G. Wilson v at A134027 *)
  • PARI
    is(n) = {my (t=digits(n,3)); if (t==Vecrev(t), my (b=[], d); while (n, b=concat(d=[0,1,-1][1+n%3], b); n=(n-d)/3); b==Vecrev(b), 0)} \\ Rémy Sigrist, Jun 10 2022
Showing 1-10 of 13 results. Next