Let $f(n)$ = 1 if $n$ belongs to [A014689](https://oeis.org/A014689), $\operatorname{prime}(n)-n$, the number of nonprimes less than $\operatorname{prime}(n)$. Here $\operatorname{prime}(n)$ is the $n$-th prime number, $\operatorname{prime}(1)=2$.


Let $a(n)$ be the $n$-th composite numbers, $a(1)=4$.


Then I conjecture that


$$a(n) = 1 + a(n-1) + f(n)$$


Is there a way to prove it?



Difference between $n$-th and $(n-1)$-th composite numbers
Surely $f(n)$ is meant to be the indicator function of the range of the function $k\mapsto p(k)-k$, where $p(k)$ denotes the $k$-th prime number. With this supplemented definition, the conjecture is true.


Indeed, $n=p(k)-k$ holds if and only if there are $n-1$ composite numbers up to $p(k)$, that is, $a(n-1)<p(k)<a(n)$. Therefore, $f(n)=1$ means that there is a prime number between $a(n-1)$ and $a(n)$. So we have $a(n)=a(n-1)+2$ when $f(n)=1$, and we have $a(n)=a(n-1)+1$ when $f(n)=0$.


