OFFSET
1,1
COMMENTS
There are three other versions: composite c with c(n) < c < 2*c(n): a(n)-2; c(n) <= c < 2*c(n): a(n) - 1; and c(n) < c <= 2*c(n): also a(n) - 1.
LINKS
N. J. A. Sloane, Table of n, a(n) for n = 1..20000
FORMULA
EXAMPLE
The 5th composite number is 10, and 10, 12, 14, 15, 16, 18, 20 are composite, so a(5) = 7.
MAPLE
chi := proc(n) if n <= 3 then 0 else n - numtheory:-pi(n) - 1; fi; end; # A065855
t := []: for n from 2 to 200000 do if not isprime(n) then t := [op(t), n]; fi; od: # precompute A002808
ithchi := proc(n) t[n]; end: # returns n-th composite number A002808 for any n <= 182015, analogous to ithprime
A376760 := proc(n) chi(2*ithchi(n)) - n + 1; end;
[seq(A376760(n), n=1..120)];
MATHEMATICA
MapIndexed[2*# - PrimePi[2*#] - #2[[1]] &, Select[Range[100], CompositeQ]] (* Paolo Xausa, Oct 22 2024 *)
PROG
(Python)
from sympy import composite, primepi
def A376760(n): return (m:=composite(n)<<1)-primepi(m)-n # Chai Wah Wu, Oct 22 2024
CROSSREFS
KEYWORD
nonn
AUTHOR
N. J. A. Sloane, Oct 22 2024
STATUS
approved