login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A121885
Excess of n-th prime over previous semiprime.
2
1, 1, 1, 3, 2, 4, 1, 3, 5, 2, 2, 4, 1, 2, 1, 3, 2, 2, 4, 2, 1, 2, 2, 6, 8, 1, 3, 2, 4, 2, 3, 5, 3, 5, 2, 2, 1, 4, 1, 3, 4, 6, 3, 5, 2, 2, 1, 3, 7, 2, 4, 2, 3, 1, 2, 4, 3, 3, 5, 2, 2, 2, 4, 3, 2, 2, 1, 3, 7, 1, 2, 2, 2, 1, 3, 2, 3, 2, 2, 4, 4, 6, 2, 6, 2, 3, 3
OFFSET
3,4
COMMENTS
See: A102415 Greatest semiprime less than n-th prime. See: A102414 Smallest semiprime greater than n-th prime.
FORMULA
a(n) = Min{A000040(n)-s for s < A000040(n) and s in A001358(k)}. a(n) = A000040(n) - A102415(n).
MATHEMATICA
SemiPrimeQ[n_Integer] := If[Abs[n] < 2, False, (2 == Plus @@ Transpose[FactorInteger[Abs[n]]][[2]])]; Table[i = Prime[n] - 1; While[! SemiPrimeQ[i], i--]; Prime[n] - i, {n, 3, 100}] (* T. D. Noe, Oct 08 2012 *)
eps[n_]:=Module[{c=n-1}, While[PrimeOmega[c]!=2, c--]; n-c]; Table[eps[n], {n, Prime[Range[3, 90]]}] (* Harvey P. Dale, Aug 12 2014 *)
PROG
(PARI) dsemi(n)= { local(k=0); if(isprime(n), k=0; while(bigomega(n-k)<>2&&k<n, k=k+1)); return(k) }
{ forprime(n=5, 10^3, print(n, " ", dsemi(n))) } \\ Antonio Roldán, Oct 08 2012
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
Jonathan Vos Post, Aug 31 2006
EXTENSIONS
Extended by T. D. Noe, Oct 08 2012
STATUS
approved