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

%I #14 Feb 04 2023 20:43:00

%S 3,12,45,171,619,2560,10774,46708,202635,904603,4073767,18604618,

%T 85445767,395944114,1837763447,8600149593

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

%C a(n) =~ Pi(10^n)/2^(n-1). _Robert G. Wilson v_, Feb 04 2023

%e 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.

%t c=1; k=0; lst={}; f[n_] := Block[{e = 10 FromDigits[2 IntegerDigits[n, 5]]}, Length@ Select[e + {1, 3, 7, 9}, PrimeQ]];

%t Do[ While[k< 5^n, c+=f@k; k++]; Print[c], {n, 0, 16}] (* _Robert G. Wilson v_, Feb 04 2023 *)

%o (Python)

%o from sympy import isprime

%o from itertools import product

%o def a(n):

%o c=3

%o if n==1:return(c)

%o x=[[1,7],[1,3,7,9],[3,9],'2468','02468']

%o for k in range(2,n+1):

%o for f in x[3]:

%o for m in product(x[4], repeat=k-2):

%o s = int(f+"".join(m))*10

%o t=s%3

%o for last in x[t]:

%o if isprime(s+last):

%o c+= 1

%o return(c)

%o print([a(n) for n in range(1,7)])

%o (Python)

%o from sympy import primerange

%o def a(n):

%o p=list(primerange(3,10**n))

%o return(sum(1 for k in p if sum(str(k).count(d) for d in '13579')==1))

%o print([a(n) for n in range(1,7)])

%Y Cf. A030096, A068690, A154764, A358685, A358690.

%K base,nonn,more

%O 1,1

%A _Zhining Yang_, Jan 14 2023

%E a(16) from _Robert G. Wilson v_, Feb 04 2023