login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A272896 Difference between the number of odd and even digits in the decimal expansion of 2^n. 1

%I #17 Mar 14 2017 20:56:01

%S 1,-1,-1,-1,0,0,-2,-1,-1,1,-2,-4,-2,0,-1,-1,1,2,-4,-4,-1,1,-1,-5,2,2,

%T -4,1,-3,1,0,-4,-2,2,3,3,1,4,-2,2,5,3,-1,-5,-2,-2,-2,1,-1,3,-4,0,2,2,

%U -1,-1,5,2,2,-4,-3,1,-5,-1,0,0,-6,3,5,5,2,-10,-8,2,-3,7,9,0,0

%N Difference between the number of odd and even digits in the decimal expansion of 2^n.

%C All vanishing entries are a(A272898(k)) = 0, k >= 1. - _Wolfdieter Lang_, May 24 2016

%H Indranil Ghosh, <a href="/A272896/b272896.txt">Table of n, a(n) for n = 0..10000</a>

%F a(n) = A055254(n) - A055253(n) = A196564(2^n) - A196563(2^n). - _Indranil Ghosh_, Mar 13 2017

%e 2^10 = 1024, 2^11 = 2048, 2^12 = 4096, 2^13 = 8192.

%e So a(10) = 1 - 3 = -2, a(11) = 0 - 4 = -4, a(12) = 1 - 3 = -2, a(13) = 2 - 2 = 0.

%t Table[Count[#, _?OddQ] - Count[#, _?EvenQ] &@ IntegerDigits[2^n], {n, 0, 100}] (* _Michael De Vlieger_, May 09 2016 *)

%o (Ruby)

%o def a(n)

%o str = (2 ** n).to_s

%o str.size - str.split('').map(&:to_i).select{|i| i % 2 == 0}.size * 2

%o end

%o (0..n).each{|i| p a(i)}

%o (PARI) a(n) = #select(x -> x%2, digits(2^n)) - #select(x -> !(x%2), digits(2^n));

%o for(n=0, 78, print1(a(n),", ")) \\ _Indranil Ghosh_, Mar 13 2017

%o (Python)

%o def A272896(n):

%o ....x=y=0

%o ....for i in str(2**n):

%o ........if int(i)%2: x+=1

%o ........else: y+=1

%o ....return x - y # _Indranil Ghosh_, Mar 13 2017

%Y Cf. A000079, A055253, A055254, A196563, A196564, A272898.

%K sign,base

%O 0,7

%A _Seiichi Manyama_, May 09 2016

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 19 16:52 EDT 2024. Contains 371794 sequences. (Running on oeis4.)