Please define a function $g(n,p)$ that gives the amount of positive integer $i$s that make the following expression a positive integer: $\frac{2n - 2i - p - 1}{2p}$, where $n$ is a given integer, where $p$ is some prime $2 \lt p \le n$, and where $i$ is some integer less than $n$. In case you use $\pi(n)$ for the prime counting function, please do not approximate it but leave it as $\pi(n)$.

  • $\begingroup$ @Peter When would this be the case? In a limit? $\endgroup$ Apr 16, 2017 at 16:11
  • $\begingroup$ Because $2i \le 2n-p-1$! $\endgroup$
    – Ghartal
    Apr 16, 2017 at 16:18
  • $\begingroup$ @Ghartal Did not notice that the expression should be positive. $\endgroup$
    – Peter
    Apr 16, 2017 at 16:22
  • $\begingroup$ @Ghartal I forgot to bound $i$. I'll fix that. $\endgroup$ Apr 16, 2017 at 16:26

1 Answer 1


If $p$ is fixed why would we need the prime counting function? Just work with the numerator $\bmod {2p}$. If $p=2$ there are no solutions because the numerator is odd. The solutions for $i$ will recur at intervals of $p$. The highest $i$ will solve $2n-2i-p-1=2p$ or $i=\frac 12(2n-3p-1).$ Now just divide that by $p$ and discard the remainder to find how many there are.

  • $\begingroup$ This is pretty clear, thanks. Just to clarify, "Now just divide that by $p$ and ..." What does "that" refer to? $\endgroup$ Apr 16, 2017 at 16:40
  • $\begingroup$ The maximum $i$ $\endgroup$ Apr 16, 2017 at 18:01
  • $\begingroup$ So $g(n,p) = \lfloor \frac{2n-3p-1}{2p} \rfloor$? $\endgroup$ Apr 16, 2017 at 18:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .