OFFSET
1,8
REFERENCES
C. K. Caldwell and H. Dubner, The near repunits primes, J. Rec. Math., Vol. 27(1), 1995, pp. 35-41.
LINKS
Charles R Greathouse IV, Table of n, a(n) for n = 1..2000
Chris Caldwell, Below are all of the 12-digit Near-Repunit primes.
Chris Caldwell, Repunits.
EXAMPLE
a(12) = 5 because from (10^12 - 1)/9 = 111111111111, by changing just one digit from 1 to 0, out of the eleven candidates, 111111111101, 111111110111, 111111011111, 111011111111 and 101111111111 are primes.
MATHEMATICA
a = {}; Do[ p = IntegerDigits[ (10^n - 1)/9 ]; c = 0; Do[ If[ q = FromDigits[ ReplacePart[p, 0, i]]; PrimeQ[q], c++ ], {i, 2, n} ]; a = Append[a, c], {n, 1, 100} ]; a (* Robert G. Wilson v, Nov 19 2001 *)
PROG
(PARI) a(n)=sum(i=1, n-2, ispseudoprime(10^n\9-10^i)) \\ Charles R Greathouse IV, May 01 2012
(Python)
from sympy import isprime
def a(n):
Rn = (10**n-1)//9
return sum(1 for i in range(n-1) if isprime(Rn-10**i))
print([a(n) for n in range(1, 101)]) # Michael S. Branicky, Nov 04 2023
CROSSREFS
KEYWORD
nonn,base
AUTHOR
EXTENSIONS
More terms from Robert G. Wilson v, Nov 19 2001
Edited by N. J. A. Sloane, Oct 02 2008 at the suggestion of R. J. Mathar
STATUS
approved