OFFSET
1,1
COMMENTS
This is a very slow-growing function. For the first 10^8 primes, the largest value is 45, which occurs for the prime 981270947.
LINKS
T. D. Noe, Table of n, a(n) for n = 1..10000
EXAMPLE
a(10)=3 because 29 is the 10th prime and the nearest semiprime is 26.
MATHEMATICA
SemiPrimeQ[n_] := (2==Plus@@(Transpose[FactorInteger[n]][[2]])); Join[{2}, Table[p=Prime[i]; j=1; While[ !SemiPrimeQ[p+j] && !SemiPrimeQ[p-j], j++ ]; j, {i, 2, 150}]]
dnsm[n_]:=Module[{k=1}, While[PrimeOmega[n-k]!=2&&PrimeOmega[n+k]!=2, k++]; k]; dnsm/@Prime[Range[90]] (* Harvey P. Dale, May 04 2019 *)
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
T. D. Noe, Jan 30 2006
STATUS
approved