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!)
A196564 Number of odd digits in decimal representation of n. 49

%I #48 Jul 25 2023 10:59:18

%S 0,1,0,1,0,1,0,1,0,1,1,2,1,2,1,2,1,2,1,2,0,1,0,1,0,1,0,1,0,1,1,2,1,2,

%T 1,2,1,2,1,2,0,1,0,1,0,1,0,1,0,1,1,2,1,2,1,2,1,2,1,2,0,1,0,1,0,1,0,1,

%U 0,1,1,2,1,2,1,2,1,2,1,2,0,1,0,1,0,1

%N Number of odd digits in decimal representation of n.

%H Reinhard Zumkeller, <a href="/A196564/b196564.txt">Table of n, a(n) for n = 0..10000</a>

%H Zachary P. Bradshaw and Christophe Vignat, <a href="https://arxiv.org/abs/2307.05565">Dubious Identities: A Visit to the Borwein Zoo</a>, arXiv:2307.05565 [math.HO], 2023.

%F a(n) = A055642(n) - A196563(n);

%F a(A014263(n)) = 0; a(A007957(n)) > 0.

%F From _Hieronymus Fischer_, May 30 2012: (Start)

%F a(n) = Sum_{j=0..m} (floor(n/(2*10^j) + (1/2)) - floor(n/(2*10^j)), where m=floor(log_10(n)).

%F a(10n+k) = a(n) + a(k), 0<=k<10, n>=0.

%F a(n) = a(floor(n/10)) + a(n mod 10), n>=0.

%F a(n) = Sum_{j=0..m} a(floor(n/10^j) mod 10), n>=0.

%F a(A014261(n)) = floor(log_5(4n+1)), n>0.

%F G.f.: g(x) = (1/(1-x))*Sum_{j>=0} x^10^j/(1+x^10^j).

%F (End)

%p A196564 := proc(n)

%p if n =0 then

%p 0;

%p else

%p convert(n,base,10) ;

%p add(d mod 2,d=%) ;

%p end if:

%p end proc: # _R. J. Mathar_, Jul 13 2012

%t Table[Total[Mod[IntegerDigits[n],2]],{n,0,100}] (* _Zak Seidov_, Oct 13 2015 *)

%o (Haskell)

%o a196564 n = length [d | d <- show n, d `elem` "13579"]

%o -- _Reinhard Zumkeller_, Feb 22 2012, Oct 04 2011

%o (PARI) a(n) = #select(x->x%2, digits(n)); \\ _Michel Marcus_, Oct 14 2015

%o (Python)

%o def a(n): return sum(1 for d in str(n) if d in "13579")

%o print([a(n) for n in range(100)]) # _Michael S. Branicky_, May 15 2022

%Y Cf. A014261, A014263, A027868, A046034, A055640, A055641, A055642, A061217, A102669-A102685, A122640, A196563.

%K nonn,easy,base

%O 0,12

%A _Reinhard Zumkeller_, Oct 04 2011

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 24 04:14 EDT 2024. Contains 371918 sequences. (Running on oeis4.)