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

A007089 Numbers in base 3.

Original entry on oeis.org

0, 1, 2, 10, 11, 12, 20, 21, 22, 100, 101, 102, 110, 111, 112, 120, 121, 122, 200, 201, 202, 210, 211, 212, 220, 221, 222, 1000, 1001, 1002, 1010, 1011, 1012, 1020, 1021, 1022, 1100, 1101, 1102, 1110, 1111, 1112, 1120, 1121, 1122, 1200, 1201, 1202, 1210, 1211
Offset: 0

Views

Author

Keywords

Comments

Nonnegative integers with no decimal digit > 2. Thus nonnegative integers in base 10 whose quadrupling by normal addition or multiplication requires no carry operation. - Rick L. Shepherd, Jun 25 2009

References

  • Jan Gullberg, Mathematics from the Birth of Numbers, W. W. Norton & Co., NY & London, 1997, §2.3 Positional Notation, p. 47.
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Programs

  • Haskell
    a007089 0 = 0
    a007089 n = 10 * a007089 n' + m where (n', m) = divMod n 3
    -- Reinhard Zumkeller, Feb 19 2012
    
  • Maple
    A007089 := proc(n) option remember;
    if n <= 0 then 0
    else
      if (n mod 3) = 0 then 10*procname(n/3) else procname(n-1) + 1 fi
    fi end:
    [seq(A007089(n), n=0..729)]; # - N. J. A. Sloane, Mar 09 2019
  • Mathematica
    Table[ FromDigits[ IntegerDigits[n, 3]], {n, 0, 50}]
  • PARI
    a(n)=if(n<1,0,if(n%3,a(n-1)+1,10*a(n/3)))
    
  • PARI
    a(n)=fromdigits(digits(n,3)) \\ Charles R Greathouse IV, Jan 08 2017
    
  • Python
    def A007089(n):
      n,s = divmod(n,3); t = 1
      while n: n,r = divmod(n,3); t *= 10; s += r*t
      return s # M. F. Hasler, Feb 15 2023

Formula

a(0)=0, a(n) = 10*a(n/3) if n==0 (mod 3), a(n) = a(n-1) + 1 otherwise. - Benoit Cloitre, Dec 22 2002
a(n) = 10*a(floor(n/3)) + (n mod 3) if n > 0, a(0) = 0. - M. F. Hasler, Feb 15 2023

Extensions

More terms from James Sellers, May 01 2000

A000523 a(n) = floor(log_2(n)).

Original entry on oeis.org

0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 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, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6
Offset: 1

Views

Author

Keywords

Comments

Or, n >= 0 appears 2^n times. - Jon Perry, Sep 21 2002
a(n) + 1 = number of bits in binary expansion of n.
Largest power of 2 dividing lcm(1..n): A007814(A003418(n)).
log_2(0) = -infinity.
Also Max_{k=1..n} Omega(k), where Omega(n) = A001222(n), number of prime factors with repetition; see A080613. - Reinhard Zumkeller, Feb 25 2003
From Paul Weisenhorn, Sep 29 2010, updated Aug 11 2020: (Start)
Arithmetic mean: m(1,(c+1)/c) = (2*c+1)/(2*c); harmonic mean: h(1,(c+1)/c) = 2*(c+1)/(2*c+1);
a(n) is the number of means to reach (n+1)/n from 2/1; with m for 0 and h for 1, the inverse binary expansion of n, without the leading 1, gives the sequence of means.
For example, n=20; inverse binary expansion without the leading 1: 0010 ---> m m h m or m(1, m(1, h(1, m(1, 2)))) = 21/20.
The 4 twofold means for n from 4 to 7:
m(1,m(1,2)) = m(1,3/2) = 5/4,
h(1,m(1,2)) = h(1,3/2) = 6/5,
m(1,h(1,2)) = m(1,4/3) = 7/6,
h(1,h(1,2)) = h(1,4/3) = 8/7. (End) [Edited by Petros Hadjicostas, Jul 23 2020]
As function of the absolute value, defines the minimal Euclidean function v on Z\{0}. A ring R is Euclidean if for some function v : R\{0}->N a division by nonzero b can be defined with remainder r satisfying either r=0 or v(r) < v(b). For the integers taking v(n)=|n| works, but v(n) = floor(log_2(|n|)) works as well; moreover it is the possibility with smallest possible values. For division by b>0 one can always choose |r| <= floor(b/2); this sequence satisfies a(1) = 0 and recursively a(n) = 1 + max(a(1), ..., a(floor(n/2))) for n > 1. - Marc A. A. van Leeuwen, Feb 16 2011
Maximum number of guesses required to find any k in a range of 1..n, with 'higher', 'lower' and 'correct' as answers. - Jon Perry, Nov 02 2013
Number of powers of 2 <= n. - Ralph-Joseph Tatt, Apr 23 2018
a(n) + 1 is the minimum number of pairwise disjoint subsets of an n-element set such that for each k from 1 to n there is a set with cardinality k which is the union of some of those subsets. - Wojciech Raszka, Apr 15 2019
Minimum height of an n-node binary tree. - Yuchun Ji, Mar 22 2021

Examples

			a(5)=2 because the binary expansion of 5 (=101) has three bits.
		

References

  • Rüdeger Baumann, Computer-Knobelei, LOG IN Heft 159 (2009), 74-77. - Paul Weisenhorn, Sep 29 2010
  • G. H. Hardy, Note on Dr. Vacca's series for gamma, Quart. J. Pure Appl. Math., Vol. 43 (1912), pp. 215-216.
  • Ernst Jacobsthal, Über die Eulersche konstante, Mathematisch-Naturwissenschaftliche Blätter, Vol. 3, No. 9 (1906), pp. 153-154.
  • Donald E. Knuth, The Art of Computer Programming, Vol. 1: Fundamental Algorithms, p. 400.
  • Donald E. Knuth, The Art of Computer Programming, vol. 4A, Combinatorial Algorithms, Section 7.1.3, Problem 41, p. 589. - From N. J. A. Sloane, Aug 03 2012

Crossrefs

Programs

  • Haskell
    a000523 1 = 0
    a000523 n = 1 + a000523 (div n 2)
    a000523_list = 0 : f [0] where
       f xs = ys ++ f ys where ys = map (+ 1) (xs ++ xs)
    -- Reinhard Zumkeller, Dec 31 2012, Feb 04 2012, Mar 18 2011
    
  • Magma
    [Ilog2(n) : n in [1..130] ];
    
  • Maple
    A000523 := proc(n)
        ilog2(n) ;
    end proc: # R. J. Mathar, Nov 28 2016
    seq(A000523(n), n=1..90);
  • Mathematica
    Floor[Log[2,Range[110]]] (* Harvey P. Dale, Jul 16 2012 *)
    a[ n_] := If[ n < 1, 0, BitLength[n] - 1]; (* Michael Somos, Jul 10 2018 *)
  • PARI
    {a(n) = floor(log(n) / log(2))} \\ Likely to yield incorrect results for many if not almost all n. Better use most recent code.
    
  • PARI
    {a(n) = if( n<1, 0, #binary(n) - 1)}; /* Michael Somos, May 28 2014 */
    
  • PARI
    a(n)=logint(n,2) \\ Charles R Greathouse IV, Sep 01 2015
    
  • PARI
    a(n)=exponent(n) \\ Charles R Greathouse IV, Nov 09 2017
    
  • Python
    def A000523(n):
        return len(bin(n))-3 # Chai Wah Wu, Jul 09 2020
    
  • Python
    def a(n): return n.bit_length() - 1
    print([a(n) for n in range(1, 106)]) # Michael S. Branicky, Apr 18 2023

Formula

a(n) = A070939(n) - 1 for n >= 1.
a(n) = if n > 1, then a(floor(n / 2)) + 1; else 0. - Reinhard Zumkeller, Oct 29 2001
G.f.: (1/(1 - x)) * Sum_{k>=1} x^2^k. - Ralf Stephan, Apr 13 2002
a(n+1) = number of digits of n-th number with no 0 in ternary representation = A081604(A032924(n)); A107680(n) = A003462(a(n+1)). - Reinhard Zumkeller, May 20 2005
a(n) = A152487(n-1,0) = A152487(n,1). - Reinhard Zumkeller, Dec 06 2008
a(n) = k with 2^k <= n < 2^(k+1); a(n) = floor(log_2(n)). - Paul Weisenhorn, Sep 29 2010
a(n) = Max_{k=1..n} A240857(n,k). - Reinhard Zumkeller, Apr 14 2014
a(n) = A113473(n) - 1. - Filip Zaludek, Oct 29 2016
Sum_{n>=2} (-1)^n*a(n)/n = gamma = A001620 (Jacobsthal, 1906; Vacca, 1910). - Amiram Eldar, Jun 12 2021
a(n) = floor(Sum_{k=1..n-1} (n+1)^(n-2^k)) mod n. - Joseph M. Shunia, Jul 19 2024

Extensions

Error in 4th term, pointed out by Joe Keane (jgk(AT)jgk.org), has been corrected.
More terms from Michael Somos, Aug 02 2002

A081603 Number of 2's in ternary representation of n.

Original entry on oeis.org

0, 0, 1, 0, 0, 1, 1, 1, 2, 0, 0, 1, 0, 0, 1, 1, 1, 2, 1, 1, 2, 1, 1, 2, 2, 2, 3, 0, 0, 1, 0, 0, 1, 1, 1, 2, 0, 0, 1, 0, 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, 0, 0, 1, 0, 0, 1, 1, 1, 2, 0, 0, 1, 0, 0, 1, 1, 1, 2, 1, 1, 2, 1, 1, 2
Offset: 0

Views

Author

Reinhard Zumkeller, Mar 23 2003

Keywords

Comments

Fixed point of the morphism: 0 ->001; 1 ->112; 2 ->223; 3 ->334, etc., starting from a(0)=0. - Philippe Deléham, Oct 26 2011

Crossrefs

Programs

  • Haskell
    a081603 0 = 0
    a081603 n = a081603 n' + m `div` 2 where (n',m) = divMod n 3
    -- Reinhard Zumkeller, Feb 21 2013
    
  • Maple
    A081603 := proc(n)
        local a,d ;
        a := 0 ;
        for d in convert(n,base,3) do
            if d= 2 then
                a := a+1 ;
            end if;
        end do:
        a;
    end proc: # R. J. Mathar, Jul 12 2016
  • Mathematica
    Table[Count[IntegerDigits[n,3],2],{n,0,6!}] (* Vladimir Joseph Stephan Orlovsky, Jul 25 2009 *)
    Nest[ Flatten[# /. a_Integer -> {a, a, a + 1}] &, {0}, 5] (* Robert G. Wilson v, May 20 2014 *)
    DigitCount[Range[0,120],3,2] (* Harvey P. Dale, Jul 10 2019 *)
  • PARI
    a(n)=hammingweight(digits(n,3)\2); \\ Ruud H.G. van Tol, Dec 10 2023
    
  • Python
    from gmpy2 import digits
    def A081603(n): return digits(n,3).count('2') # Chai Wah Wu, Dec 05 2024

Formula

a(n) = floor(n/2) if n < 3, otherwise a(floor(n/3)) + floor((n mod 3)/2).
A077267(n) + A062756(n) + a(n) = A081604(n);
a(n) = (A053735(n) - A062756(n))/2.

A030341 Triangle T(n,k): write n in base 3, reverse order of digits.

Original entry on oeis.org

0, 1, 2, 0, 1, 1, 1, 2, 1, 0, 2, 1, 2, 2, 2, 0, 0, 1, 1, 0, 1, 2, 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 1, 0, 2, 1, 1, 2, 1, 2, 2, 1, 0, 0, 2, 1, 0, 2, 2, 0, 2, 0, 1, 2, 1, 1, 2, 2, 1, 2, 0, 2, 2, 1, 2, 2, 2, 2, 2, 0, 0, 0, 1, 1, 0, 0, 1, 2, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 2, 1, 0, 1
Offset: 0

Views

Author

Keywords

Examples

			Triangle begins :
0
1
2
0, 1
1, 1
2, 1
0, 2
1, 2
2, 2
0, 0, 1
1, 0, 1
2, 0, 1
0, 1, 1
1, 1, 1
2, 1, 1 ...
		

Crossrefs

Cf. A081604 (row lengths), A053735 (row sums), A007089, A003137.
Cf. A030308, A030386, A031235, A030567, A031007, A031045, A031087, A031298 for the base-2 to base-10 analogs.

Programs

  • Haskell
    a030341 n k = a030341_tabf !! n !! k
    a030341_row n = a030341_tabf !! n
    a030341_tabf = iterate succ [0] where
       succ []     = [1]
       succ (2:ts) = 0 : succ ts
       succ (t:ts) = (t + 1) : ts
    -- Reinhard Zumkeller, Feb 21 2013
    
  • Maple
    A030341_row := n -> op(convert(n, base, 3)):
    seq(A030341_row(n), n=0..32); # Peter Luschny, Nov 28 2017
  • Mathematica
    Flatten[Table[Reverse[IntegerDigits[n,3]],{n,0,40}]] (* Harvey P. Dale, Oct 20 2014 *)
  • PARI
    A030341(n, k=-1)=/*k<0&&error("Flattened sequence not yet implemented.")*/n\3^k%3 \\ Assuming that columns are numbered starting with k=0 as in A030308, A030567 and others. - M. F. Hasler, Jul 21 2013

Extensions

Initial 0 and better name by Philippe Deléham, Oct 20 2011

A032924 Numbers whose ternary expansion contains no 0.

Original entry on oeis.org

1, 2, 4, 5, 7, 8, 13, 14, 16, 17, 22, 23, 25, 26, 40, 41, 43, 44, 49, 50, 52, 53, 67, 68, 70, 71, 76, 77, 79, 80, 121, 122, 124, 125, 130, 131, 133, 134, 148, 149, 151, 152, 157, 158, 160, 161, 202, 203, 205, 206, 211, 212, 214, 215, 229, 230, 232, 233, 238, 239
Offset: 1

Views

Author

Keywords

Comments

Complement of A081605. - Reinhard Zumkeller, Mar 23 2003
Subsequence of A154314. - Reinhard Zumkeller, Jan 07 2009
The first 28 terms are the range of A059852 (Morse codes for letters, when written in base 3) union {44, 50} (which correspond to Morse codes of Ü and Ä). Subsequent terms represent the Morse code of other symbols in the same coding. - M. F. Hasler, Jun 22 2020

Crossrefs

Zeroless numbers in some other bases <= 10: A000042 (base 2), A023705 (base 4), A248910 (base 6), A255805 (base 8), A255808 (base 9), A052382 (base 10).

Programs

  • Haskell
    a032924 n = a032924_list !! (n-1)
    a032924_list = iterate f 1 where
       f x = 1 + if r < 2 then x else 3 * f x'  where (x', r) = divMod x 3
    -- Reinhard Zumkeller, Mar 07 2015, May 04 2012
    
  • Maple
    f:= proc(n) local L,i,m;
       L:= convert(n,base,2);
       m:= nops(L);
       add((1+L[i])*3^(i-1),i=1..m-1);
    end proc:
    map(f, [$2..101]); # Robert Israel, Aug 04 2015
  • Mathematica
    Select[Range@ 240, Last@ DigitCount[#, 3] == 0 &] (* Michael De Vlieger, Aug 05 2015 *)
    Flatten[Table[FromDigits[#,3]&/@Tuples[{1,2},n],{n,5}]] (* Harvey P. Dale, May 28 2016 *)
  • PARI
    apply( {A032924(n)=if(n<3,n,3*self()((n-1)\2)+2-n%2)}, [1..99]) \\ M. F. Hasler, Jun 22 2020
    
  • PARI
    a(n) = fromdigits(apply(d->d+1,binary(n+1)[^1]), 3); \\ Kevin Ryde, Jun 23 2020
    
  • Python
    def a(n): return sum(3**i*(int(b)+1) for i, b in enumerate(bin(n+1)[:2:-1]))
    print([a(n) for n in range(1, 61)]) # Michael S. Branicky, Aug 15 2022
    
  • Python
    def is_A032924(n):
        while n > 2:
           n,r = divmod(n,3)
           if r==0: return False
        return n > 0
    print([n for n in range(250) if is_A032924(n)]) # M. F. Hasler, Feb 15 2023
    
  • Python
    def A032924(n): return int(bin(m:=n+1)[3:],3) + (3**(m.bit_length()-1)-1>>1) # Chai Wah Wu, Oct 13 2023

Formula

a(n) = A107680(n) + A107681(n). - Reinhard Zumkeller, May 20 2005
A081604(A107681(n)) <= A081604(A107680(n)) = A081604(a(n)) = A000523(n+1). - Reinhard Zumkeller, May 20 2005
A077267(a(n)) = 0. - Reinhard Zumkeller, Mar 02 2008
a(1)=1, a(n+1) = f(a(n)+1,a(n)+1) where f(x,y) = if x<3 and x<>0 then y, else if x mod 3 = 0 then f(y+1,y+1), else f(floor(x/3),y). - Reinhard Zumkeller, Mar 02 2008
a(2*n) = a(2*n-1)+1, n>0. - Zak Seidov, Jul 27 2009
A212193(a(n)) = 0. - Reinhard Zumkeller, May 04 2012
a(2*n+1) = 3*a(n)+1. - Robert Israel, Aug 05 2015
G.f.: x/(1-x)^2 + Sum_{m >= 1} 3^(m-1)*x^(2^(m+1)-1)/((1-x^(2^m))*(1-x)). - Robert Israel, Aug 04 2015
A065361(a(n)) = n. - Rémy Sigrist, Feb 06 2023
Sum_{n>=1} 1/a(n) = 3.4977362637842652509313189236131190039368413460747606236619907531632476445332666030262441154353753276457... (calculated using Baillie and Schmelzer's kempnerSums.nb, see Links). - Amiram Eldar, Apr 14 2025

A077267 Number of zeros in base-3 expansion of n.

Original entry on oeis.org

1, 0, 0, 1, 0, 0, 1, 0, 0, 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, 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, 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
Offset: 0

Views

Author

Henry Bottomley, Nov 01 2002

Keywords

Examples

			a(8)=0 since 8 written in base 3 is 22 with 0 zeros;
a(9)=2 since 9 written in base 3 is 100 with 2 zeros;
a(10)=1 since 10 written in base 3 is 101 with 1 zero.
		

Crossrefs

Programs

Formula

a(1)=a(2)=0; a(3n)=a(n)+1; a(3n+1)=a(3n+2)=a(n). a(3^n-2)=a(3^n-1)=0; a(3^n)=n. a(n)=A077266(n, 3).
a(n) + A062756(n) + A081603(n) = A081604(n). - Reinhard Zumkeller, Mar 23 2003
G.f.: (Sum_{k>=0} x^(3^(k+1))/(1 + x^(3^k) + x^(2*3^k)))/(1-x). - Franklin T. Adams-Watters, Nov 03 2005
a(n) = A079978(n) if n < 3, A079978(n) + a(floor(n/3)) otherwise. - Reinhard Zumkeller, Feb 21 2013

Extensions

a(0)=1 added, offset changed to 0 and b-file adjusted by Reinhard Zumkeller, Feb 21 2013
Wrong formula deleted by Reinhard Zumkeller, Feb 21 2013

A003137 Write n in base 3 and juxtapose.

Original entry on oeis.org

1, 2, 1, 0, 1, 1, 1, 2, 2, 0, 2, 1, 2, 2, 1, 0, 0, 1, 0, 1, 1, 0, 2, 1, 1, 0, 1, 1, 1, 1, 1, 2, 1, 2, 0, 1, 2, 1, 1, 2, 2, 2, 0, 0, 2, 0, 1, 2, 0, 2, 2, 1, 0, 2, 1, 1, 2, 1, 2, 2, 2, 0, 2, 2, 1, 2, 2, 2, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 2, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 2, 1, 0, 2, 0, 1, 0, 2, 1, 1, 0, 2, 2, 1
Offset: 1

Views

Author

Keywords

Comments

An irregular table in which the n-th row lists the base-3 digits of n, see A007089. - Jason Kimberley, Dec 07 2012
The base-3 Champernowne constant (A077771): it is normal in base 3. - Jason Kimberley, Dec 07 2012

Examples

			1,
2,
1,0,
1,1,
1,2,
2,0,
2,1,
2,2,
1,0,0,
1,0,1,.... _R. J. Mathar_, Aug 16 2021
		

References

  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Tables in which the n-th row lists the base b digits of n: A030190 and A030302 (b=2), this sequence and A054635 (b=3), A030373 (b=4), A031219 (b=5), A030548 (b=6), A030998 (b=7), A031035 and A054634 (b=8), A031076 (b=9), A007376 and A033307 (b=10). - Jason Kimberley, Dec 06 2012
Cf. A081604 (row lengths), A053735 (row sums), A030341 (rows reversed), A077771, A007089.

Programs

  • Haskell
    a003137 n k = a003137_tabf !! (n-1) !! k
    a003137_row n = a003137_tabf !! (n-1)
    a003137_tabf = map reverse $ tail a030341_tabf
    a003137_list = concat a003137_tabf
    -- Reinhard Zumkeller, Feb 21 2013
    
  • Magma
    &cat[Reverse(IntegerToSequence(n,3)):n in[1..31]]; // Jason Kimberley, Dec 07 2012
    
  • Mathematica
    Flatten@ IntegerDigits[ Range@ 40, 3] (* or *)
    almostNatural[n_, b_] := Block[{m = 0, d = n, i = 1, l, p}, While[m <= d, l = m; m = (b - 1) i*b^(i - 1) + l; i++]; i--; p = Mod[d - l, i]; q = Floor[(d - l)/i] + b^(i - 1); If[p != 0, IntegerDigits[q, b][[p]], Mod[q - 1, b]]]; Array[ a[#, 3] &, 105] (* Robert G. Wilson v, Jul 01 2014 *)
  • Python
    from itertools import count, islice
    from sympy.ntheory.factor_ import digits
    def A003137_gen(): return (d for m in count(1) for d in digits(m,3)[1:])
    A003137_list = list(islice(A003137_gen(),30)) # Chai Wah Wu, Jan 07 2022

Extensions

More terms from Larry Reeves (larryr(AT)acm.org), Sep 25 2000

A054635 Champernowne sequence: write n in base 3 and juxtapose.

Original entry on oeis.org

0, 1, 2, 1, 0, 1, 1, 1, 2, 2, 0, 2, 1, 2, 2, 1, 0, 0, 1, 0, 1, 1, 0, 2, 1, 1, 0, 1, 1, 1, 1, 1, 2, 1, 2, 0, 1, 2, 1, 1, 2, 2, 2, 0, 0, 2, 0, 1, 2, 0, 2, 2, 1, 0, 2, 1, 1, 2, 1, 2, 2, 2, 0, 2, 2, 1, 2, 2, 2, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 2, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 2, 1, 0, 2, 0, 1, 0, 2, 1
Offset: 0

Views

Author

N. J. A. Sloane, Apr 16 2000

Keywords

Comments

Essentially the same as A003137. - R. J. Mathar, Aug 29 2009
An irregular table in which the n-th row lists the base-3 digits of n. - Jason Kimberley, Dec 07 2012
The base-3 Champernowne constant (A077771): it is normal in base 3. - Jason Kimberley, Dec 07 2012

Crossrefs

Cf. A054637 (partial sums).
Cf. A081604 (row lengths), A053735 (row sums), A030341 (rows reversed), A007089, A077771.
Table in which the n-th row lists the base b digits of n: A030190 and A030302 (b=2), A003137 and this sequence (b=3), A030373 (b=4), A031219 (b=5), A030548 (b=6), A030998 (b=7), A031035 and A054634 (b=8), A031076 (b=9), A007376 and A033307 (b=10). - Jason Kimberley, Dec 06 2012

Programs

  • Haskell
    a054635 n k = a054635_tabf !! n !! k
    a054635_row n = a054635_tabf !! n
    a054635_tabf = map reverse a030341_tabf
    a054635_list = concat a054635_tabf
    -- Reinhard Zumkeller, Feb 21 2013
    
  • Magma
    [0]cat &cat[Reverse(IntegerToSequence(n,3)):n in[1..31]]; // Jason Kimberley, Dec 07 2012
    
  • Mathematica
    almostNatural[n_, b_] := Block[{m = 0, d = n, i = 1, l, p}, While[m <= d, l = m; m = (b - 1) i*b^(i - 1) + l; i++]; i--; p = Mod[d - l, i]; q = Floor[(d - l)/i] + b^(i - 1); If[p != 0, IntegerDigits[q, b][[p]], Mod[q - 1, b]]]; Array[ almostNatural[#, 3] &, 105, 0] (* Robert G. Wilson v, Jun 29 2014 *)
    First[RealDigits[ChampernowneNumber[3], 3, 100, 0]] (* Paolo Xausa, Jun 19 2024 *)
  • Python
    from sympy.ntheory.digits import digits
    def agen(limit):
        for n in range(limit):
            yield from digits(n, 3)[1:]
    print([an for an in agen(35)]) # Michael S. Branicky, Sep 01 2021

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

A246435 Length of representation of n in fractional base 3/2.

Original entry on oeis.org

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

Views

Author

Reinhard Zumkeller, Sep 05 2014

Keywords

Crossrefs

Cf. A024629, A055642, A070989, A081604, A081848 (run lengths), A244040.

Programs

  • Haskell
    a246435 n = if n < 3 then 1 else a246435 (2 * div n 3) + 1
    -- Reinhard Zumkeller, Sep 05 2014
    
  • Mathematica
    a[n_] := If[n < 3, 1, a[2 Quotient[n, 3]] + 1]; Array[a, 100, 0] (* Jean-François Alcover, Feb 05 2019 *)
  • PARI
    a(n) = if(n < 3, 1, a(n\3 * 2) + 1); \\ Amiram Eldar, Jul 30 2025

Formula

a(n) = if n < 3 then 1, otherwise a(2*floor(n/3)) + 1.
a(n) = A055642(A024629(n)).
Showing 1-10 of 38 results. Next