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.

A104638 Number of odd digits in n-th prime.

Original entry on oeis.org

0, 1, 1, 1, 2, 2, 2, 2, 1, 1, 2, 2, 1, 1, 1, 2, 2, 1, 1, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 3, 2, 3, 3, 3, 2, 3, 3, 2, 2, 3, 3, 2, 3, 3, 3, 3, 2, 1, 1, 1, 2, 2, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 3, 3, 3, 3, 3, 2, 2, 3, 3, 2, 3, 3, 2, 2, 3, 1, 1, 2, 1, 2, 2, 2, 1, 1, 2, 1, 1, 1, 2, 1, 2, 2, 2, 2, 2, 2, 2
Offset: 1

Views

Author

Zak Seidov, Mar 18 2005

Keywords

Comments

The only zero is the first term. Sequence is unbounded. - Zak Seidov, Jan 12 2016
From Robert Israel, Jan 12 2016: (Start)
For any N, the asymptotic density of terms >= N is 1.
On the other hand, a(n) = 2 if prime(n) is in A159352, which is conjectured to be infinite.
Record values: a(2) = 1, a(5) = 2, a(30) = 3, a(187) = 4, a(1346) = 5, a(10545) = 6, a(86538) = 7, a(733410) = 8.
(End)

Crossrefs

Cf. A154764 (1 odd digit), A155071 (2 odd digits), A030096 (all digits odd).

Programs

  • Maple
    seq(nops(select(type, convert(ithprime(i),base,10),odd)),i=1..100); # Robert Israel, Jan 12 2016
    # alternative
    A104638 := proc(n)
        local a,dgs,d ;
        ithprime(n) ;
        dgs := convert(%,base,10) ;
        a := 0 ;
        for d in dgs do
            a := a+modp(d,2) ;
        end do:
        a ;
    end proc:
    seq(A104638(n),n=1..40) ; # R. J. Mathar, Jul 13 2025
  • Mathematica
    Table[Count[IntegerDigits[Prime[n]],?OddQ],{n,100}] (* _Harvey P. Dale, Jan 22 2012 *)
    Table[Total[Mod[IntegerDigits[Prime[n]], 2]], {n, 100}] (* Vincenzo Librandi, Jan 13 2016 *)
  • PARI
    a(n)=vecsum(digits(prime(n)%2)) \\ Zak Seidov, Jan 12 2016

Formula

a(n) = A196564(A000040(n)). - Michel Marcus, Oct 05 2013