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

%I #24 Mar 01 2018 03:04:18

%S 4,8,10,9,12,11,8,4,9,9,10,14,14,11,16,7,10,17,7,10,9,12,9,13,11,10,

%T 14,5,3,22,6,13,13,10,8,16,8,6,16,8,13,14,8,7,8,13,9,11,13,9,14,8,4,

%U 23,13,11,8,8,8,12,13,13,11,11,10,23,11,8,8,3,6,16,12,13,12,12,8,11,8,11,14,13,7,15,12,17,11,7,9,21,6,6,11,12,6,14,14,12,13,12,11,17,10,17,18

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

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

%e a(2) = 8 from 17, 37, 47, 67, 71, 73, 79, 97. - _N. J. A. Sloane_, Dec 27 2015

%e a(3) = 10 since 277, 577, 677, 727, 757, 773, 787, 797, 877, and 977 are primes.

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

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

%o (Python)

%o from __future__ import division

%o from sympy import isprime

%o def A266146(n):

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

%Y Cf. A265733, A266141, A266142, A266143, A266144, A266145, A266147, A266148, A266149, A099419, A099420, A098089.

%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) corrected in b-file as above by _Andrew Howroyd_, Feb 28 2018