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”).

A026238
a(n) = j if n is the j-th prime, else a(n) = k if n is the k-th composite.
7
1, 2, 1, 3, 2, 4, 3, 4, 5, 5, 6, 6, 7, 8, 9, 7, 10, 8, 11, 12, 13, 9, 14, 15, 16, 17, 18, 10, 19, 11, 20, 21, 22, 23, 24, 12, 25, 26, 27, 13, 28, 14, 29, 30, 31, 15, 32, 33, 34, 35, 36, 16, 37, 38, 39, 40, 41, 17, 42, 18, 43, 44, 45, 46, 47, 19
OFFSET
2,2
LINKS
FORMULA
a(n) = A049084(n) + A066246(n) for n >= 2.
MATHEMATICA
Table[If[PrimeQ[n], PrimePi[n], n-1-PrimePi[n]], {n, 2, 70}] (* Harvey P. Dale, Jun 06 2017 *)
PROG
(Haskell)
a026238 n = a049084 n + a066246 n -- Reinhard Zumkeller, Jan 29 2014
(PARI) first(n)=my(c, p); vector(n-1, k, if(isprime(k+1), p++, c++)) \\ Charles R Greathouse IV, Sep 02 2015
CROSSREFS
KEYWORD
nonn
STATUS
approved