login
A266148
Number of n-digit primes in which n-1 of the digits are 9's.
11
4, 6, 7, 7, 8, 10, 7, 13, 8, 8, 11, 13, 8, 11, 13, 14, 10, 9, 7, 11, 9, 13, 10, 19, 5, 10, 14, 7, 10, 9, 9, 15, 13, 8, 7, 9, 10, 11, 10, 13, 5, 12, 15, 7, 12, 7, 12, 11, 13, 11, 8, 13, 13, 13, 12, 12, 9, 9, 15, 14, 9, 8, 13, 11, 15, 17, 10, 8, 11, 10, 6, 16, 8, 8, 8, 15, 9, 11, 14, 7, 10, 11, 16, 17, 11, 10, 12, 16, 8, 15, 7, 11, 11, 10, 7, 12, 6, 10, 8, 9
OFFSET
1,1
COMMENTS
The other digit cannot be 0, 3, 6, or 9, or else the number would not be prime. - N. J. A. Sloane, May 20 2016
LINKS
Dana Jacobsen, Table of n, a(n) for n = 1..2500 (first 1215 terms from Michael De Vlieger and Robert G. Wilson v)
EXAMPLE
a(3) = 7 since 199, 499, 599, 919, 929, 991 and 997 are all the three-digit primes containing two 9's.
MATHEMATICA
f9[n_] := Block[{cnt = k = 0, r = 9 (10^n - 1)/9, s = Range[0, 9] - 9}, While[k < n, cnt += Length@ Select[r + 10^k * s, PrimeQ@ # && IntegerLength@ # > k &]; k++]; cnt]; Array[f9, 100]
PROG
(Python)
from sympy import isprime
def A266148(n):
return sum(1 for d in range(-9, 1) for i in range(n) if isprime(10**n-1+d*10**i)) # Chai Wah Wu, Dec 31 2015
(Perl) use ntheory ":all"; sub a266148 { my $n = shift; vecsum( map { my $k=$_; scalar grep { is_prime("9" x $k . $_ . "9" x ($n-$k-1)) } 0+($k>0) .. 8 } 0 .. $n-1 ); } # Dana Jacobsen, Jan 01 2016
KEYWORD
base,nonn
AUTHOR
STATUS
approved