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.

A260683 Number of 2's in the expansion of 2^n in base 3.

Original entry on oeis.org

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

Views

Author

Emmanuel Vantieghem, Nov 15 2015

Keywords

Comments

Erdős conjectures that a(n) > 0 for n > 8.

Examples

			For n=5, the expansion of 2^n in number base 3 is 1012, thus: a(n)=1
For n=10, the expansion of 2^n in number base 3 is 1101221, thus: a(n)=2
		

References

  • R. K. Guy, Unsolved Problems in Number Theory, B33. [Does not seem to be in section B33.]

Crossrefs

Cf. A004642 (2^n in base 3), A020915 (number of terms), A036461 (number of 1's), A104320 (number of 0's).
Cf. A000108 (conjecture that A000108(n) is 6m+1 only for n = 0, 1 and 5 follows from Erdős's one).
Cf. A005836 (for numbers with no 2 in base 3).

Programs

  • Maple
    seq(numboccur(2, convert(2^n,base,3)),n=0..100); # Robert Israel, Nov 15 2015
  • Mathematica
    S={};n=-1;While[n<150,n++;A=IntegerDigits[2^n,3];k=Count[A,2];AppendTo[S, k]];S
  • PARI
    c(k, d, b) = {my(c=0, f); while (k>b-1, f=k-b*(k\b); if (f==d, c++); k\=b); if (k==d, c++); return(c)}
    for(n=0, 300, print1(c(2^n, 2, 3)", ")) \\ Altug Alkan, Nov 15 2015
    
  • PARI
    a(n) = #select(x->(x==2), digits(2^n, 3)); \\ Michel Marcus, Nov 28 2018
    
  • PARI
    a(n) = hammingweight(digits(2^n, 3)\2); \\ Ruud H.G. van Tol, May 09 2024
    
  • Perl
    use ntheory ":all"; sub a260683 { scalar grep { $==2 } todigits(vecprod((2) x shift), 3) } # _Dana Jacobsen, Aug 16 2016

Formula

a(n) = A020915(n) - A104320(n) - A036461(n). - Altug Alkan, Nov 15 2015
a(n) = A081603(A000079(n)). - Michel Marcus, Dec 03 2015