OFFSET
1,1
COMMENTS
Sequence is monotonically increasing starting from a(2). a(n) = a(n+1) if and only if both prime(n)+2 and composite(n)+1 are prime. - Jianing Song, Jun 27 2021
LINKS
Reinhard Zumkeller, Table of n, a(n) for n = 1..10000
FORMULA
MATHEMATICA
composite[n_Integer] := Block[{k=n+PrimePi[n]+1}, While[k-PrimePi[k]-1 != n, k++]; k]; Table[Prime[n] - composite[n], {n, 65}] (* corrected by Harvey P. Dale, Aug 08 2011 *)
Module[{nn=300, prs, cmps, len}, prs=Prime[Range[PrimePi[nn]]]; cmps= Complement[ Range[4, nn], prs]; len=Min[Length[prs], Length[cmps]]; #[[1]]- #[[2]]&/@ Thread[{Take[prs, len], Take[cmps, len]}]] (* Harvey P. Dale, Jun 18 2015 *)
PROG
(Haskell)
a038529 n = a000040 n - a002808 n -- Reinhard Zumkeller, Apr 30 2014
(Python)
from sympy import prime, composite
def A038529(n):
return prime(n)-composite(n) # Chai Wah Wu, Dec 27 2018
CROSSREFS
KEYWORD
sign,easy
AUTHOR
Vasiliy Danilov (danilovv(AT)usa.net), Jul 14 1998
STATUS
approved