OFFSET
1,1
FORMULA
10^n - a(n) is prime and 10^n - k is composite for 0 <= k < a(n). - corrected by David A. Corneth, Aug 18 2016
EXAMPLE
10^1 = 3 + 7, 10^2 = 3 + 97, 10^3 = 3 + 997, 10^4 = 59 + 9941, 10^5 = 11 + 99989, 10^6 = 17 + 999983, 10^7 = 29 + 9999971, 10^8 = 11 + 99999989, 10^9 = 71 + 999999929, 10^10 = 71 + 9999999929, etc.
MATHEMATICA
Table[DeleteCases[Map[{#, 10^n - #} &, Prime@ Range@ PrimePi@ Floor[10^n/2]] /. {_, k_} /; ! PrimeQ@ k -> 0, 0][[1, 1]], {n, 8}] (* or *)
Table[First@ SelectFirst[Map[{#, 10^n - #} &, Prime@ Range@ PrimePi@ Floor[10^n/2]], PrimeQ@ Last@ # &], {n, 9}] (* Version 10, Michael De Vlieger, Aug 01 2016 *)
lp[n_]:=Module[{p=3, x=10^n}, While[CompositeQ[x-p], p=NextPrime[p]]; p]; Array[lp, 60] (* Harvey P. Dale, Jun 11 2022 *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Zak Seidov, Nov 02 2006
EXTENSIONS
a(1) corrected and a(2) inserted by Gionata Neri, Aug 01 2016
STATUS
approved