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.

A359813 Number of primes < 10^n with exactly one odd decimal digit.

Original entry on oeis.org

3, 12, 45, 171, 619, 2560, 10774, 46708, 202635, 904603, 4073767, 18604618, 85445767, 395944114, 1837763447, 8600149593
Offset: 1

Views

Author

Zhining Yang, Jan 14 2023

Keywords

Comments

a(n) =~ Pi(10^n)/2^(n-1). Robert G. Wilson v, Feb 04 2023

Examples

			a(2)=12 as there are 12 primes less than 100 with exactly one odd decimal digit: 3, 5, 7, 23, 29, 41, 43, 47, 61, 67, 83, 89.
		

Crossrefs

Programs

  • Mathematica
    c=1; k=0; lst={}; f[n_] := Block[{e = 10 FromDigits[2 IntegerDigits[n, 5]]}, Length@ Select[e + {1, 3, 7, 9}, PrimeQ]];
    Do[ While[k< 5^n, c+=f@k; k++]; Print[c], {n, 0, 16}] (* Robert G. Wilson v, Feb 04 2023 *)
  • Python
    from sympy import isprime
    from itertools import  product
    def a(n):
        c=3
        if n==1:return(c)
        x=[[1,7],[1,3,7,9],[3,9],'2468','02468']
        for k in range(2,n+1):
            for f in x[3]:
                for m in product(x[4], repeat=k-2):
                    s = int(f+"".join(m))*10
                    t=s%3
                    for last in x[t]:
                        if isprime(s+last):
                            c+= 1
        return(c)
    print([a(n) for n in range(1,7)])
    
  • Python
    from sympy import primerange
    def a(n):
        p=list(primerange(3,10**n))
        return(sum(1 for k in p if sum(str(k).count(d) for d in '13579')==1))
    print([a(n) for n in range(1,7)])

Extensions

a(16) from Robert G. Wilson v, Feb 04 2023