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.

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

This page as a plain text file.
%I A272896 #19 May 22 2025 10:21:44
%S A272896 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 A272896 -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 A272896 -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 A272896 Difference between the number of odd and even digits in the decimal expansion of 2^n.
%C A272896 All vanishing entries are a(A272898(k)) = 0, k >= 1. - _Wolfdieter Lang_, May 24 2016
%H A272896 Indranil Ghosh, <a href="/A272896/b272896.txt">Table of n, a(n) for n = 0..10000</a>
%F A272896 a(n) = A055254(n) - A055253(n) = A196564(2^n) - A196563(2^n). - _Indranil Ghosh_, Mar 13 2017
%e A272896 2^10 = 1024, 2^11 = 2048, 2^12 = 4096, 2^13 = 8192.
%e A272896 So a(10) = 1 - 3 = -2, a(11) = 0 - 4 = -4, a(12) = 1 - 3 = -2, a(13) = 2 - 2 = 0.
%t A272896 Table[Count[#, _?OddQ] - Count[#, _?EvenQ] &@ IntegerDigits[2^n], {n, 0, 100}] (* _Michael De Vlieger_, May 09 2016 *)
%o A272896 (Ruby)
%o A272896 def a(n)
%o A272896   str = (2 ** n).to_s
%o A272896   str.size - str.split('').map(&:to_i).select{|i| i % 2 == 0}.size * 2
%o A272896 end
%o A272896 (0..n).each{|i| p a(i)}
%o A272896 (PARI) a(n) = #select(x -> x%2, digits(2^n)) - #select(x -> !(x%2), digits(2^n));
%o A272896 for(n=0, 78, print1(a(n),", ")) \\ _Indranil Ghosh_, Mar 13 2017
%o A272896 (Python)
%o A272896 def A272896(n):
%o A272896     x=y=0
%o A272896     for i in str(2**n):
%o A272896         if int(i)%2: x+=1
%o A272896         else: y+=1
%o A272896     return x - y # _Indranil Ghosh_, Mar 13 2017
%Y A272896 Cf. A000079, A055253, A055254, A196563, A196564, A272898.
%K A272896 sign,base
%O A272896 0,7
%A A272896 _Seiichi Manyama_, May 09 2016