login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A266142
Number of n-digit primes in which n-1 of the digits are 3's.
11
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, 10, 10, 12, 7, 14, 14, 15, 7, 16, 11, 7, 14, 10, 13, 13, 8, 10, 11, 12, 6, 12, 10, 10, 10, 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
OFFSET
1,1
LINKS
Michael De Vlieger and Robert G. Wilson v, Table of n, a(n) for n = 1..1215
EXAMPLE
a(2) = 8 since 13, 23, 31, 37, 43, 53, 73 and 83 are all primes.
a(3) = 9 since 233, 313, 331, 337, 353, 373, 383, 433 and 733 are all primes.
MATHEMATICA
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]
PROG
(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
(Python)
from __future__ import division
from sympy import isprime
def A266142(n):
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
KEYWORD
base,nonn
AUTHOR
EXTENSIONS
a(2) corrected by Chai Wah Wu, Dec 27 2015
a(2) in b-file corrected as above by Andrew Howroyd, Feb 28 2018
STATUS
approved