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-7 of 7 results.

A132141 Numbers whose ternary representation begins with 1.

Original entry on oeis.org

1, 3, 4, 5, 9, 10, 11, 12, 13, 14, 15, 16, 17, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108
Offset: 1

Views

Author

Reinhard Zumkeller, Aug 20 2007

Keywords

Comments

The lower and upper asymptotic densities of this sequence are 1/2 and 3/4, respectively. - Amiram Eldar, Feb 28 2021

Crossrefs

Programs

  • Haskell
    a132141 n = a132141_list !! (n-1)
    a132141_list = filter ((== 1) . until (< 3) (flip div 3)) [1..]
    -- Reinhard Zumkeller, Feb 06 2015
  • Mathematica
    Flatten[(Range[3^#,2 3^#-1])&/@Range[0,4]] (* Zak Seidov, Mar 03 2009 *)
  • PARI
    s=[];for(n=0,4,for(x=3^n,2*3^n-1,s=concat(s,x)));s \\ Zak Seidov, Mar 03 2009
    
  • PARI
    a(n) = n + 3^logint(n<<1,3) >> 1; \\ Kevin Ryde, Feb 19 2022
    

Formula

A number n is a term iff 3^m <= n < 2*3^m -1, for m=0,1,2,... - Zak Seidov, Mar 03 2009
a(n) = n + (3^floor(log_3(2*n)) - 1)/2. - Kevin Ryde, Feb 19 2022

A134026 Numbers that are in balanced ternary representation longer than in ternary representation.

Original entry on oeis.org

2, 5, 6, 7, 8, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131
Offset: 1

Views

Author

Reinhard Zumkeller, Oct 19 2007

Keywords

Comments

A157671 is a subsequence. - Reinhard Zumkeller, Jan 20 2010

Crossrefs

Complement of A134025.

Programs

  • Mathematica
    Select[Range[150], Ceiling[Log[3, 2*#+1]] > IntegerLength[#, 3] &] (* Amiram Eldar, Apr 03 2025 *)

Formula

a(n) = g(n,0,0) with g(n,m,k) = if n=0 then k else if k=3^m-1 then g(n-1,m,3*(k+1)/2+1) else g(n-1,m,k+1).
A134021(a(n)) = A081604(a(n)) + 1.
A171960(a(n)) < a(n). - Reinhard Zumkeller, Jan 20 2010

A338246 Nonpositive values in A117966, in order of appearance and negated.

Original entry on oeis.org

0, 1, 3, 2, 4, 9, 8, 10, 6, 5, 7, 12, 11, 13, 27, 26, 28, 24, 23, 25, 30, 29, 31, 18, 17, 19, 15, 14, 16, 21, 20, 22, 36, 35, 37, 33, 32, 34, 39, 38, 40, 81, 80, 82, 78, 77, 79, 84, 83, 85, 72, 71, 73, 69, 68, 70, 75, 74, 76, 90, 89, 91, 87, 86, 88, 93, 92, 94
Offset: 0

Views

Author

Rémy Sigrist, Oct 18 2020

Keywords

Comments

This sequence is a self-inverse permutation of the nonnegative integers (the offset has been set to 0 so as to get a permutation).

Examples

			A117966 = 0, 1, -1, 3, 4, 2, -3, -2, -4, 9, 10, 8, 12, 13, 11, 6, 7, 5, -9, ...
We keep:  0,     1,           3,  2,  4,                                 9, ...
		

Crossrefs

Cf. A003462 (fixed points), A117966, A157671, A338245.

Programs

  • PARI
    A117966(n) = subst(Pol(apply(x->if(x == 2, -1, x), digits(n, 3)), 'x), 'x, 3)
    print (-select(v -> v<=0, apply(A117966, [0..188])))

Formula

a(0) = 0.
a(n) = -A117966(A157671(n)) for any n > 0.
a(n) = n iff n belongs to A003462.

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

A328749 a(n) = Sum_{k = 0..w and t_k > 0} (-1)^t_k * 2^k, where Sum_{k = 0..w} t_k * 3^k is the ternary representation of n.

Original entry on oeis.org

0, -1, 1, -2, -3, -1, 2, 1, 3, -4, -5, -3, -6, -7, -5, -2, -3, -1, 4, 3, 5, 2, 1, 3, 6, 5, 7, -8, -9, -7, -10, -11, -9, -6, -7, -5, -12, -13, -11, -14, -15, -13, -10, -11, -9, -4, -5, -3, -6, -7, -5, -2, -3, -1, 8, 7, 9, 6, 5, 7, 10, 9, 11, 4, 3, 5, 2, 1, 3, 6
Offset: 0

Views

Author

Rémy Sigrist, Oct 27 2019

Keywords

Comments

Every integer appears in the sequence.

Examples

			a(42) = a(1*3^3 + 1*3^2 + 2*3^1) = -2^3 - 2^2 + 2^1 = -10.
		

Crossrefs

Programs

  • PARI
    a(n) = my (d=Vecrev(digits(n,3))); sum(i=1, #d, if (d[i], (2^i) * (-1)^d[i], 0))/2
    
  • Python
    from sympy.ntheory.factor_ import digits
    def A328749(n): return sum((-(1<0) # Chai Wah Wu, Apr 12 2023

Formula

a(n) = 0 iff n = 0.
a(n) > 0 iff n belongs to A157671.
a(n) < 0 iff n belongs to A132141.
a(A004488(n)) = -a(n).

A333773 Replace 2's with (-1)'s in ternary representation of n and sum nonzero terms with alternating signs.

Original entry on oeis.org

0, 1, -1, 3, 2, 4, -3, -4, -2, 9, 8, 10, 6, 7, 5, 12, 13, 11, -9, -10, -8, -12, -11, -13, -6, -5, -7, 27, 26, 28, 24, 25, 23, 30, 31, 29, 18, 19, 17, 21, 20, 22, 15, 14, 16, 36, 37, 35, 39, 38, 40, 33, 32, 34, -27, -28, -26, -30, -29, -31, -24, -23, -25, -36
Offset: 0

Views

Author

Rémy Sigrist, Apr 05 2020

Keywords

Comments

This sequence is a variant of A117966, and shares features with A065620.
Every integer appears exactly once in this sequence.

Examples

			For n = 97:
- 97 = 3^4 + 3^2 + 2*3^1 + 3^0,
- hence a(97) = 3^4 - 3^2 + (-1)*3^1 - 3^0 = 68.
		

Crossrefs

Programs

  • PARI
    a(n) = { my (v=0, t=Vecrev(digits(n,3))); for (k=1, #t, if (t[k]==1, v=+3^(k-1)-v, t[k]==2, v=-3^(k-1)-v)); v }

Formula

a(3*n) = 3*a(n).
a(3*n+1) = 3*a(n) + (-1)^A160384(n).
a(3*n+2) = 3*a(n) - (-1)^A160384(n).
Sum_{k=0..n} a(k) >= 0 with equality iff n belongs to A024023.
a(n) > 0 iff n belongs to A132141.
a(n) < 0 iff n belongs to A157671.
a(A004488(n)) = -a(n).

A370925 Rectangular array, read by antidiagonals: row n consists of the numbers m whose ternary representation starts with 2 and has exactly n runs.

Original entry on oeis.org

2, 8, 6, 26, 7, 19, 80, 18, 20, 57, 242, 22, 21, 59, 172, 728, 24, 23, 60, 173, 516, 2186, 25, 55, 61, 177, 518, 1549, 6560, 54, 56, 64, 178, 519, 1550, 4647, 19682, 67, 58, 65, 181, 520, 1554, 4649, 13942
Offset: 1

Views

Author

Clark Kimberling, Mar 13 2024

Keywords

Comments

Every positive integer occurs in this array or A370924.

Examples

			Corner:
       2     8    26    80   242   728  2186
       6     7    18    22    24    25    54
      19    20    21    23    55    56    58
      57    59    60    61    64    65    69
     172   173   177   178   181   182   183
     516   518   519   520   532   533   534
    1549  1550  1554  1555  1558  1559  1560
		

Crossrefs

Programs

  • Mathematica
    d[n_] := First[IntegerDigits[n, 3]];
    a[n_] := a[n] = Select[Range[30000],
    d[#] == 2 && Length[Split[IntegerDigits[#, 3]]] == n &];
    t[n_, k_] := a[n][[k]];
    Grid[Table[t[n, k], {n, 1, 10}, {k, 1, 10}]] (* array *)
    Table[t[n - k + 1, k], {n, 10}, {k, n, 1, -1}] // Flatten (* sequence *)
Showing 1-7 of 7 results.