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 39 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

A062756 Number of 1's in ternary (base-3) expansion of n.

Original entry on oeis.org

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

Views

Author

Ahmed Fares (ahmedfares(AT)my-deja.com), Jul 16 2001

Keywords

Comments

Fixed point of the morphism: 0 ->010; 1 ->121; 2 ->232; ...; n -> n(n+1)n, starting from a(0)=0. - Philippe Deléham, Oct 25 2011

Crossrefs

Cf. A080846, A343785 (first differences).
Cf. A081606 (indices of !=0).
Indices of terms 0..6: A005823, A023692, A023693, A023694, A023695, A023696, A023697.
Numbers of: A077267 (0's), A081603 (2's), A160384 (1's+2's).
Other bases: A000120, A160381, A268643.

Programs

  • Haskell
    a062756 0 = 0
    a062756 n = a062756 n' + m `mod` 2 where (n',m) = divMod n 3
    -- Reinhard Zumkeller, Feb 21 2013
    
  • Mathematica
    Table[Count[IntegerDigits[i, 3], 1], {i, 0, 200}]
    Nest[Join[#, # + 1, #] &, {0}, 5] (* IWABUCHI Yu(u)ki, Sep 08 2012 *)
  • PARI
    a(n)=if(n<1,0,a(n\3)+(n%3)%2) \\ Paul D. Hanna, Feb 24 2006
    
  • PARI
    a(n)=hammingweight(digits(n,3)%2); \\ Ruud H.G. van Tol, Dec 10 2023
    
  • Python
    from sympy.ntheory import digits
    def A062756(n): return digits(n,3)[1:].count(1) # Chai Wah Wu, Dec 23 2022

Formula

a(0) = 0, a(3n) = a(n), a(3n+1) = a(n)+1, a(3n+2) = a(n). - Vladeta Jovovic, Jul 18 2001
G.f.: (Sum_{k>=0} x^(3^k)/(1+x^(3^k)+x^(2*3^k)))/(1-x). In general, the generating function for the number of digits equal to d in the base b representation of n (0 < d < b) is (Sum_{k>=0} x^(d*b^k)/(Sum_{i=0..b-1} x^(i*b^k)))/(1-x). - Franklin T. Adams-Watters, Nov 03 2005 [For d=0, use the above formula with d=b: (Sum_{k>=0} x^(b^(k+1))/(Sum_{i=0..b-1} x^(i*b^k)))/(1-x), adding 1 if you consider the representation of 0 to have one zero digit.]
a(n) = a(floor(n/3)) + (n mod 3) mod 2. - Paul D. Hanna, Feb 24 2006

Extensions

More terms from Vladeta Jovovic, Jul 18 2001

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.

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

A081604 Number of digits in ternary representation of n.

Original entry on oeis.org

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

Views

Author

Reinhard Zumkeller, Mar 23 2003

Keywords

Comments

a(n) is the length of row n in table A054635. - Reinhard Zumkeller, Sep 05 2014

Examples

			a(8) = 2 because 8 = 22_3, having 2 digits.
a(9) = 3 because 9 = 100_3, having 3 digits.
		

Crossrefs

Programs

  • Haskell
    a081604 n = if n < 3 then 1 else a081604 (div n 3) + 1
    -- Reinhard Zumkeller, Sep 05 2014, Feb 21 2013
  • Maple
    A081604 := proc(n)
        max(1,1+ilog[3](n)) ;
    end proc: # R. J. Mathar, Jul 12 2016
  • Mathematica
    Table[Length[IntegerDigits[n, 3]], {n, 0, 99}] (* Alonso del Arte, Dec 30 2012 *)
    Join[{1},IntegerLength[Range[120],3]] (* Harvey P. Dale, Apr 07 2019 *)

Formula

a(n) = A062153(n) + 1 for n >= 1.
a(n) = A077267(n) + A062756(n) + A081603(n);
From Reinhard Zumkeller, Oct 19 2007: (Start)
0 <= A134021(n) - a(n) <= 1;
a(A134025(n)) = A134021(A134025(n));
a(A134026(n)) = A134021(A134026(n)) - 1. (End)
a(n+1) = -Sum_{k=1..n} mu(3*k)*floor(n/k). - Benoit Cloitre, Oct 21 2009
a(n) = floor(log_3(n)) + 1. - Can Atilgan and Murat Erşen Berberler, Dec 05 2012
a(n) = if n < 3 then 1 else a(floor(n/3)) + 1. - Reinhard Zumkeller, Sep 05 2014
G.f.: 1 + (1/(1 - x))*Sum_{k>=0} x^(3^k). - Ilya Gutkovskiy, Jan 08 2017

A049354 Digitally balanced numbers in base 3: equal numbers of 0's, 1's, 2's.

Original entry on oeis.org

11, 15, 19, 21, 260, 266, 268, 278, 290, 294, 302, 304, 308, 312, 316, 318, 332, 344, 348, 380, 384, 396, 410, 412, 416, 420, 424, 426, 434, 438, 450, 460, 462, 468, 500, 502, 508, 518, 520, 524, 528, 532, 534, 544, 550, 552, 572, 574, 578, 582, 586, 588, 596
Offset: 1

Views

Author

Keywords

Crossrefs

Cf. A049354-A049360. See also A061854, A037861.
Row n = 3 of A378000.

Programs

  • Haskell
    a049354 n = a049354_list !! (n-1)
    a049354_list = filter f [1..] where
       f n = t0 == a062756 n && t0 == a081603 n where t0 = a077267 n
    -- Reinhard Zumkeller, Aug 09 2014
    
  • Mathematica
    Select[Range[600],Length[Union[DigitCount[#,3]]]== 1&]
    FromDigits[#,3]&/@DeleteCases[Flatten[Permutations/@Table[PadRight[{},3n,{1,0,2}],{n,3}],1],?(#[[1]]==0&)]//Sort (* _Harvey P. Dale, May 30 2016 *)
    Select[Range@5000, Differences@DigitCount[#,3]=={0,0}&] (* Hans Rudolf Widmer, Dec 11 2021 *)
  • Python
    from sympy.ntheory import count_digits
    def ok(n): c = count_digits(n, 3); return c[0] == c[1] == c[2]
    print([k for k in range(600) if ok(k)]) # Michael S. Branicky, Nov 15 2021

Formula

A062756(a(n)) = A077267(a(n)) and A081603(a(n)) = A077267(a(n)). - Reinhard Zumkeller, Aug 09 2014

A081605 Numbers having at least one 0 in their ternary representation.

Original entry on oeis.org

0, 3, 6, 9, 10, 11, 12, 15, 18, 19, 20, 21, 24, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 42, 45, 46, 47, 48, 51, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 69, 72, 73, 74, 75, 78, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100
Offset: 1

Views

Author

Reinhard Zumkeller, Mar 23 2003

Keywords

Comments

Complement of A032924.
A212193(a(n)) <> 0. [Reinhard Zumkeller, May 04 2012]

Crossrefs

Programs

  • Haskell
    import Data.List (findIndices)
    a081605 n = a081605_list !! (n-1)
    a081605_list = findIndices (/= 0) a212193_list
    -- Reinhard Zumkeller, May 04 2012
    
  • Mathematica
    Select[Range[0,100],DigitCount[#,3,0]>0&] (* Harvey P. Dale, Aug 10 2021 *)
  • Python
    from itertools import count, islice
    def A081605_gen(): # generator of terms
        a = -1
        for n in count(2):
            b = int(bin(n)[3:],3) + (3**(n.bit_length()-1)-1>>1)
            yield from range(a+1,b)
            a = b
    A081605_list = list(islice(A081605_gen(),30)) # Chai Wah Wu, Oct 13 2023

A370853 Numbers m such that c(0) < c(1) < c(2), where c(k) = number of k's in the ternary representation of m.

Original entry on oeis.org

17, 23, 25, 53, 71, 77, 79, 134, 152, 158, 160, 161, 206, 212, 214, 215, 230, 232, 233, 238, 239, 241, 296, 314, 320, 322, 350, 386, 398, 402, 404, 422, 428, 430, 440, 452, 456, 458, 464, 466, 470, 474, 476, 478, 480, 482, 484, 485, 530, 536, 538, 554, 556
Offset: 1

Views

Author

Clark Kimberling, Mar 03 2024

Keywords

Examples

			The ternary representation of 17 is 122, for which c(0)=0 < c(1)=1 < c(2)=2.
		

Crossrefs

Programs

  • Mathematica
    Select[Range[1000], DigitCount[#, 3, 0] < DigitCount[#, 3, 1] < DigitCount[#, 3, 2] &]
  • PARI
    check(m) = {my(c0=0, c1=0, c2=0, s=Vec(digits(m, 3)));
    for(i=1, length(s), if(s[i]==0, c0+=1, if(s[i]==1, c1+=1, if(s[i]==2, c2+=1,))));
    c0John Tyler Rascoe, Mar 11 2024

A033095 Number of 1's when n is written in base b for 2<=b<=n+1.

Original entry on oeis.org

1, 1, 3, 4, 6, 6, 9, 6, 10, 10, 12, 11, 16, 13, 15, 14, 16, 13, 18, 15, 21, 20, 21, 16, 24, 20, 23, 23, 26, 25, 32, 22, 26, 25, 25, 28, 34, 28, 32, 30, 35, 30, 37, 31, 35, 36, 35, 31, 41, 34, 37, 36, 39, 35, 43, 38, 44, 41, 42, 38, 49, 40, 43
Offset: 1

Views

Author

Keywords

Crossrefs

Programs

  • Mathematica
    f[n_] := Count[Flatten@ Table[ IntegerDigits[n, b], {b, 2, n + 1}], 1]; Array[f, 63] (* Robert G. Wilson v, Nov 14 2012 *)

Formula

G.f.: x+(Sum_{b>=2} (Sum_{k>=0} x^(b^k)/(Sum_{0<=iFranklin T. Adams-Watters, Nov 03 2005

A291770 A binary encoding of the zeros in ternary representation of n.

Original entry on oeis.org

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

Views

Author

Antti Karttunen, Sep 11 2017

Keywords

Comments

The ones in the binary representation of a(n) correspond to the nonleading zeros in the ternary representation of n. For example: ternary(33) = 1020 and binary(a(33)) = 101 (a(33) = 5).

Examples

			   n      a(n)    ternary(n)  binary(a(n))
                  A007089(n)  A007088(a(n))
  --      ----    ----------  ------------
   1        0            1           0
   2        0            2           0
   3        1           10           1
   4        0           11           0
   5        0           12           0
   6        1           20           1
   7        0           21           0
   8        0           22           0
   9        3          100          11
  10        2          101          10
  11        2          102          10
  12        1          110           1
  13        0          111           0
  14        0          112           0
  15        1          120           1
  16        0          121           0
  17        0          122           0
  18        3          200          11
  19        2          201          10
  20        2          202          10
  21        1          210           1
  22        0          211           0
  23        0          212           0
  24        1          220           1
  25        0          221           0
  26        0          222           0
  27        7         1000         111
  28        6         1001         110
  29        6         1002         110
  30        5         1010         101
		

Crossrefs

Programs

  • Mathematica
    Table[FromDigits[IntegerDigits[n, 3] /. k_ /; k < 3 :> If[k == 0, 1, 0], 2], {n, 110}] (* Michael De Vlieger, Sep 11 2017 *)
  • Python
    from sympy.ntheory.factor_ import digits
    def a(n):
        k=digits(n, 3)[1:]
        return int("".join('1' if i==0 else '0' for i in k), 2)
    print([a(n) for n in range(1, 111)]) # Indranil Ghosh, Sep 21 2017
  • Scheme
    (define (A291770 n) (if (zero? n) n (let loop ((n n) (b 1) (s 0)) (if (< n 3) s (let ((d (modulo n 3))) (if (zero? d) (loop (/ n 3) (+ b b) (+ s b)) (loop (/ (- n d) 3) (+ b b) s)))))))
    

Formula

For all n >= 0, a(A000244(n)) = A000225(n), that is, a(3^n) = (2^n) - 1. [The records in the sequence].
For all n >= 1, A000120(a(n)) = A077267(n).
For all n >= 1, A278222(a(n)) = A291771(n).
Showing 1-10 of 39 results. Next