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.

A196564 Number of odd digits in decimal representation of n.

Original entry on oeis.org

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, 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, 0, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 0, 1, 0, 1, 0, 1
Offset: 0

Views

Author

Reinhard Zumkeller, Oct 04 2011

Keywords

Crossrefs

Programs

  • Haskell
    a196564 n = length [d | d <- show n, d `elem` "13579"]
    -- Reinhard Zumkeller, Feb 22 2012, Oct 04 2011
    
  • Maple
    A196564 := proc(n)
            if n =0 then
                    0;
            else
                    convert(n,base,10) ;
                    add(d mod 2,d=%) ;
            end if:
    end proc: # R. J. Mathar, Jul 13 2012
  • Mathematica
    Table[Total[Mod[IntegerDigits[n],2]],{n,0,100}] (* Zak Seidov, Oct 13 2015 *)
  • PARI
    a(n) = #select(x->x%2, digits(n)); \\ Michel Marcus, Oct 14 2015
    
  • Python
    def a(n): return sum(1 for d in str(n) if d in "13579")
    print([a(n) for n in range(100)]) # Michael S. Branicky, May 15 2022

Formula

a(n) = A055642(n) - A196563(n);
a(A014263(n)) = 0; a(A007957(n)) > 0.
From Hieronymus Fischer, May 30 2012: (Start)
a(n) = Sum_{j=0..m} (floor(n/(2*10^j) + (1/2)) - floor(n/(2*10^j))), where m=floor(log_10(n)).
a(10*n+k) = a(n) + a(k), 0<=k<10, n>=0.
a(n) = a(floor(n/10)) + a(n mod 10), n>=0.
a(n) = Sum_{j=0..m} a(floor(n/10^j) mod 10), n>=0.
a(A014261(n)) = floor(log_5(4*n+1)), n>0.
G.f.: g(x) = (1/(1-x))*Sum_{j>=0} x^10^j/(1+x^10^j). (End)