login
Number of n-digit primes in which n-1 of the digits are 3's.
11

%I #36 Mar 02 2018 11:18:10

%S 4,8,9,12,7,14,13,11,8,7,9,8,3,10,11,14,9,12,6,11,11,11,9,10,9,10,22,

%T 10,10,12,7,14,14,15,7,16,11,7,14,10,13,13,8,10,11,12,6,12,10,10,10,

%U 11,5,14,8,8,5,14,6,18,13,9,13,10,4,14,12,6,11,13,12,20,11,9,13,6,12,22,13,10,10,12,5,20,11,10,11,10,11,12,11,13,12,18,7,20,15,6,8,8,8,15,12,10,14

%N Number of n-digit primes in which n-1 of the digits are 3's.

%H Michael De Vlieger and Robert G. Wilson v, <a href="/A266142/b266142.txt">Table of n, a(n) for n = 1..1215</a>

%e a(2) = 8 since 13, 23, 31, 37, 43, 53, 73 and 83 are all primes.

%e a(3) = 9 since 233, 313, 331, 337, 353, 373, 383, 433 and 733 are all primes.

%t f3[n_] := Block[{cnt = k = 0, r = 3 (10^n - 1)/9, s = Range[0, 9] - 3}, While[k < n, cnt += Length@ Select[r + 10^k*s, PrimeQ@ # && IntegerLength@ # > k &]; k++]; cnt]; Array[f3, 105]

%o (PARI) a(n)={sum(i=0 ,n-1, sum(d=i==n-1, 9, isprime((10^n-1)/3 + (d-3)*10^i)))} \\ _Andrew Howroyd_, Feb 28 2018

%o (Python)

%o from __future__ import division

%o from sympy import isprime

%o def A266142(n):

%o return 4*n if (n==1 or n==2) else sum(1 for d in range(-3,7) for i in range(n) if isprime((10**n-1)//3+d*10**i)) # _Chai Wah Wu_, Dec 27 2015

%Y Cf. A265733, A266141, A266143, A266144, A266145, A266146, A266147, A266148, A266149, A055557, A099411.

%K base,nonn

%O 1,1

%A _Michael De Vlieger_ and _Robert G. Wilson v_, Dec 21 2015

%E a(2) corrected by _Chai Wah Wu_, Dec 27 2015

%E a(2) in b-file corrected as above by _Andrew Howroyd_, Feb 28 2018