Prove that for all positive integers $m$ and $n$ the following inequality hold: $$\pi(m)-\pi(n)\leq\frac{(m-1)\varphi(n)}{n}$$When does equality hold? Proposed by Shend Zhjeqi and Dorlir Ahmeti, Kosovo
Problem
Source: Kosovo TST 2020 Problem 4
Tags: number theory
09.02.2020 02:10
Discard the case when $n=1$ or $n\geqslant m$, in which the equality holds when $(n,m)=(1,1),(1,2),(1,3)$. For each prime $p$ that $n<p\leqslant m$, write $p=nk+r$ for some $r\in \{ 0,1,2,\dotsc ,n-1\}$. Clearly, $r\neq 0$ and $\gcd (r,n)=1$. So, there are $\varphi (n)$ possibilities for $r$. For each fixed $r$, we have $k\geqslant 1$ and $nk+1\leqslant p\leqslant m\implies k\leqslant (m-1)/n$. So, there are $\lfloor (m-1)/n\rfloor$ possibilities for $k$. This yields the desired inequality. Equality holds only if $\lfloor (m-1)/n\rfloor = (m-1)/n\implies n\mid m-1$. Let $m=nt+1$ for some positive integer $t$. When $n\geqslant 3$, there exists $1<r_0<n$ that $\gcd(r_0,n)=1$. Equality holds only if $nt+r_0$ is a prime not greater than $m=nt+1$, which is impossible. So, the only case left is $n=2$. We want $\pi (m)=(m+1)/2$. $m$ must be odd. $2$ and $3,5,7,\dotsc ,m$ must be prime. This gives $m=3,5,7$.
09.02.2020 02:23
ThE-dArK-lOrD wrote: Discard the case when $n=1$ or $n\geqslant m$, in which the equality holds when $(n,m)=(1,1),(1,2),(1,3)$. For each prime $p$ that $n<p\leqslant m$, write $p=nk+r$ for some $r\in \{ 0,1,2,\dotsc ,n-1\}$. Clearly, $r\neq 0$ and $\gcd (r,n)=1$. So, there are $\varphi (n)$ possibilities for $r$. For each fixed $r$, we have $k\geqslant 1$ and $nk+1\leqslant p\leqslant m\implies k\leqslant (m-1)/n$. So, there are $\lfloor (m-1)/n\rfloor$ possibilities for $k$. This yields the desired inequality. Equality holds only if $\lfloor (m-1)/n\rfloor = (m-1)/n\implies n\mid m-1$. Let $m=nt+1$ for some positive integer $t$. When $n\geqslant 3$, there exists $1<r_0<n$ that $\gcd(r_0,n)=1$. Equality holds only if $nt+r_0$ is a prime not greater than $m=nt+1$, which is impossible. So, the only case left is $n=2$. We want $\pi (m)=(m+1)/2$. $m$ must be odd. $2$ and all odd numbers not greater than $m$ must be prime. This gives $m=3,5,7$. Very nice solution. It is very similarly as official one but I also think it would be good to write how you come up for cases $n=1$ and for $n\geq m$. I'm not doubting that you don't know just I think it will good for others to se the full solution as it should. Also as ThE-dArK-lOrD wrote just to see more clear. The equality cases are $(m,n)=(1,1),(2,1),(3,1),(3,2),(5,2),(7,2)$.
17.10.2020 01:23
Solved with nukelauncher. If \(m\le n\), the inequality obviously holds, with equality if and only if \((m,n)=(1,1)\). Henceforth \(m>n\). We first verify the bound. The goal is to show there are at most \(\frac{m-1}n\varphi(n)\) primes in \(\{n+1,\ldots,m\}\). Let \(f_n(S)\) denote the number of elements of \(S\) relatively prime to \(n\). I will prove the stronger inequality \[f(\{n+1,\ldots,M\})\le\frac{m-1}n\varphi(n).\] Let \(K=\left\lceil\frac{m-n}n\right\rceil\cdot n\), so \(K\le m-1\); then \begin{align*} f(\{n+1,\ldots,M\})&=f(\{1,\ldots,m-n\})\le f(\{1,\ldots,K\})\\ &=\left\lceil\frac{m-n}n\right\rceil\cdot\varphi(n)\le\frac{m-1}n\varphi(n), \end{align*}as claimed. Now for the equality bound to hold: all elements of \(\{n+1,\ldots,m\}\) must be prime; no elements of \(\{m-n+1,\ldots,K\}\) are relatively prime to \(n\); and \(\left\lceil\frac{m-n}n\right\rceil=\frac{m-1}n\), i.e.\ \(m\equiv1\pmod n\) and \(K=m-1\). If \(n\ge3\), for the second condition to hold we must have \(\gcd(K-1,n)\ne1\), which is absurd; therefore \(n\le2\). For \(n=1\), everything in \(\{2,\ldots,m\}\) must be prime, so \(m\le3\). Both \((2,1)\) and \((3,1)\) work. For \(n=2\), all odds in \(\{3,\ldots,m\}\) need to be prime, so \(m\le7\). We can verify \((3,2)\), \((5,2)\), \((7,2)\) all work. Therefore the solution set is \((1,1)\), \((2,1)\), \((3,1)\), \((3,2)\), \((5,2)\), \((7,2)\).