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

%I #51 May 09 2024 05:13:30

%S 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,

%T 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,

%U 15,11,15,16,14,14,12,14,15,14,16,11,18,11,17,10

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

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

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

%H Robert Israel, <a href="/A260683/b260683.txt">Table of n, a(n) for n = 0..10000</a>

%H Paul Erdős, <a href="https://www.jstor.org/stable/2689842">Some unconventional problems in number theory</a>, Mathematics Magazine, Vol. 52, No. 2 (1979), pp. 67-70.

%F a(n) = A020915(n) - A104320(n) - A036461(n). - _Altug Alkan_, Nov 15 2015

%F a(n) = A081603(A000079(n)). - _Michel Marcus_, Dec 03 2015

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

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

%p seq(numboccur(2, convert(2^n,base,3)),n=0..100); # _Robert Israel_, Nov 15 2015

%t S={};n=-1;While[n<150,n++;A=IntegerDigits[2^n,3];k=Count[A,2];AppendTo[S, k]];S

%o (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)}

%o for(n=0, 300, print1(c(2^n, 2, 3)", ")) \\ _Altug Alkan_, Nov 15 2015

%o (PARI) a(n) = #select(x->(x==2), digits(2^n, 3)); \\ _Michel Marcus_, Nov 28 2018

%o (PARI) a(n) = hammingweight(digits(2^n, 3)\2); \\ _Ruud H.G. van Tol_, May 09 2024

%o (Perl) use ntheory ":all"; sub a260683 { scalar grep { $_==2 } todigits(vecprod((2) x shift), 3) } # _Dana Jacobsen_, Aug 16 2016

%Y Cf. A004642 (2^n in base 3), A020915 (number of terms), A036461 (number of 1's), A104320 (number of 0's).

%Y Cf. A000108 (conjecture that A000108(n) is 6m+1 only for n = 0, 1 and 5 follows from Erdős's one).

%Y Cf. A005836 (for numbers with no 2 in base 3).

%K base,easy,nonn

%O 0,4

%A _Emmanuel Vantieghem_, Nov 15 2015