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

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

A226636 Numbers whose base-3 sum of digits is 3.

Original entry on oeis.org

5, 7, 11, 13, 15, 19, 21, 29, 31, 33, 37, 39, 45, 55, 57, 63, 83, 85, 87, 91, 93, 99, 109, 111, 117, 135, 163, 165, 171, 189, 245, 247, 249, 253, 255, 261, 271, 273, 279, 297, 325, 327, 333, 351, 405, 487, 489, 495, 513, 567, 731, 733, 735, 739, 741, 747, 757
Offset: 1

Views

Author

Tom Edgar, Aug 31 2013

Keywords

Comments

All of the entries are odd.
Subsequence of A005408. - Michel Marcus, Sep 03 2013
In general, the set of numbers with sum of base-b digits equal to b is a subset of { (b-1)*k + 1; k = 2, 3, 4, ... }. - M. F. Hasler, Dec 23 2016

Examples

			The ternary expansion of 5 is (1,2), which has sum of digits 3.
The ternary expansion of 31 is (1,0,0,2), which has sum of digits 3.
10 is not on the list since the ternary expansion of 10 is (1,0,1), which has sum of digits 2 not 3.
		

Crossrefs

Cf. A226969 (b = 4), A227062 (b = 5), A227080 (b = 6), A227092 (b = 7), A227095 (b = 8), A227238 (b = 9), A052224 (b = 10).

Programs

  • Maple
    N:= 10: # for all terms < 3^(N+1)
    [seq(seq(seq(3^a+3^b+3^c, c=0..`if`(b=a, b-1,b)),b = 0..a),a=0..N)]; # Robert Israel, Jun 05 2018
  • Mathematica
    Select[Range@ 757, Total@ IntegerDigits[#, 3] == 3 &] (* Michael De Vlieger, Dec 23 2016 *)
  • PARI
    select( is(n)=sumdigits(n,3)==3, [1..999]) \\ M. F. Hasler, Dec 23 2016
    
  • Python
    from itertools import islice
    def nextsod(n, base):
        c, b, w = 0, base, 0
        while True:
            d = n%b
            if d+1 < b and c:
                return (n+1)*b**w + ((c-1)%(b-1)+1)*b**((c-1)//(b-1))-1
            c += d; n //= b; w += 1
    def A226636gen(sod=3, base=3): # generator of terms for any sod, base
        an = (sod%(base-1)+1)*base**(sod//(base-1))-1
        while True: yield an; an = nextsod(an, base)
    print(list(islice(A226636gen(), 57))) # Michael S. Branicky, Jul 10 2022, generalizing the code by M. F. Hasler in A052224
  • Sage
    [i for i in [0..1000] if sum(Integer(i).digits(base=3))==3]
    

Formula

a(k^3/6 + k^2 + 5*k/6 + j) = 3^(k+1) + A055235(j-1) for 1 <= j <= k^2/2+5*k/2+2. - Robert Israel, Jun 05 2018

A281004 Numbers with exactly 3 ones in both binary and ternary representations.

Original entry on oeis.org

13, 37, 41, 49, 67, 97, 131, 133, 145, 193, 259, 265, 273, 289, 385, 517, 529, 577, 1027, 1029, 1033, 1041, 1153, 1281, 2053, 2057, 4101, 4105, 4113, 4129, 4161, 6145, 8195, 8197, 8209, 8225, 8257, 8321, 8449, 8705, 10241, 16449, 17409, 18433, 20481, 24577, 32771, 32777, 32785, 32801, 32833, 32897
Offset: 1

Views

Author

Robert Israel, Jan 12 2017

Keywords

Comments

Intersection of A014311 and A023694.
All terms are odd, since n == A062756(n) (mod 2).
It is likely that a(136) = 1099528404993 is the last term. The next term, if any, is greater than 10^200.

Examples

			a(4) = 49 = 110001_2 = 1211_3.
		

Crossrefs

Cf. A014311, A023694, A062756. Contains A280997.

Programs

  • Maple
    R:= NULL: count:= 0:
    for a from 2 while count < 136 do
      for b from 1 to a-1  do
        p:= 2^a + 2^b + 1;
        if numboccur(1, convert(p,base,3)) = 3 then
          count:= count+1;
          R:= R, p;
        fi
    od od:
    R;
Showing 1-3 of 3 results.