login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A038529 n-th prime - n-th composite. 8
-2, -3, -3, -2, 1, 1, 3, 4, 7, 11, 11, 16, 19, 19, 22, 27, 32, 33, 37, 39, 40, 45, 48, 53, 59, 62, 63, 65, 65, 68, 81, 83, 88, 89, 98, 99, 103, 108, 111, 116, 121, 121, 129, 130, 133, 134, 145, 155, 158, 159, 161, 165, 166, 175, 180, 185, 189, 190, 195, 197, 198, 207 (list; graph; refs; listen; history; text; internal format)
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
FORMULA
a(n) = A000040(n) - A002808(n). - Reinhard Zumkeller, Apr 30 2014
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
Sequence in context: A334223 A171414 A270921 * A176259 A132312 A090431
KEYWORD
sign,easy
AUTHOR
Vasiliy Danilov (danilovv(AT)usa.net), Jul 14 1998
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified July 21 00:10 EDT 2024. Contains 374461 sequences. (Running on oeis4.)