A055254 Number of odd digits in 2^n.
1, 0, 0, 0, 1, 1, 0, 1, 1, 2, 1, 0, 1, 2, 2, 2, 3, 4, 1, 1, 3, 4, 3, 1, 5, 5, 2, 5, 3, 5, 5, 3, 4, 6, 7, 7, 6, 8, 5, 7, 9, 8, 6, 4, 6, 6, 6, 8, 7, 9, 6, 8, 9, 9, 8, 8, 11, 10, 10, 7, 8, 10, 7, 9, 10, 10, 7, 12, 13, 13, 12, 6, 7, 12, 10, 15, 16, 12, 12, 10, 12, 13, 10, 14, 14, 12, 16, 13, 11, 13, 12
Offset: 0
Examples
2^30 = 1073741824 and 1073741824 contains 5 odd decimal digits hence a(30)=5.
References
- J. Borwein, D. Bailey and R. Girgensohn, Experimentation in mathematics : computational paths to discovery, A. K. Peters, 2004, pp. 14-15.
Links
- Seiichi Manyama, Table of n, a(n) for n = 0..10000
- D. Bowman and T. White, Proposers, Problem 6609, A rational sum, Amer. Math. Monthly, 98:3 (1991), 279-281.
- Nieuw Archief voor Wiskunde, Problemen/UWC, p174-175, June 2004.
- Jaap Spies, A Bit of Math, The Art of Problem Solving, Jaap Spies Publishers (2019).
Programs
-
Maple
A055254 := proc(val) local i, j, k, n; n := 2^val; j := 0; k := floor(ln(n)/ln(10))+1; for i from 1 to k do if (n mod 10) mod 2 = 1 then j := j+1 fi; n := floor(n/10); od; RETURN(j); end: seq(A055254(n),n=0..110); # Jaap Spies
-
Mathematica
A055254[N_] := Count[ #, True] & /@ Map[OddQ, IntegerDigits /@ (2^# & /@ Range[N])] (* This generates a table of the number of odd digits in the first N powers of two *) (* Douglas Skinner (skinnerd(AT)comcast.net), Dec 06 2007 *) Table[Count[IntegerDigits[2^n],?OddQ],{n,0,90}] (* _Harvey P. Dale, Mar 25 2015 *)
-
PARI
a(n)=my(d=digits(2^n)%2);sum(i=1,#d,d[i]) \\ Charles R Greathouse IV, Jun 04 2013
-
Perl
sub a{my $m;map $m+=1&$_,split //,1<
-
Python
def a(n): return sum(1 for d in str(1<
Michael S. Branicky, Dec 23 2022
Formula
Sum(k>=0,a(k)/2^k)=11/9 (for a proof see the comment above). [Corrected by Jaap Spies, Mar 13 2009]
Extensions
More terms from Jaap Spies, Dec 30 2003
Comments