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.

A055254 Number of odd digits in 2^n.

Original entry on oeis.org

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

Views

Author

Asher Auel, May 05 2000

Keywords

Comments

Related sequence b(n) = Number of digits in 2^n that are at least 5. a(0) = 1, b(0) = 0 and a(n+1) = b(n), as a digit with value 5 of higher in 2^n will generate an odd digit in 2^(n+1). In the Nieuw Archief voor Wiskunde link there is a proof that sum(k>=, b(k)/2^k) = 2/9. - Jaap Spies, Mar 13 2009

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.

Crossrefs

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