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?

[i]Proposed by Shend Zhjeqi and Dorlir Ahmeti, Kosovo[/i]
1. **Case Analysis for \( n = 1 \) and \( n \geq m \):**
   - When \( n = 1 \):
     \[
     \pi(m) - \pi(1) \leq \frac{(m-1)\varphi(1)}{1}
     \]
     Since \(\pi(1) = 0\) and \(\varphi(1) = 1\), the inequality becomes:
     \[
     \pi(m) \leq m - 1
     \]
     This is true because \(\pi(m)\) counts the number of primes less than or equal to \(m\), and there are at most \(m-1\) primes less than \(m\).

   - When \( n \geq m \):
     \[
     \pi(m) - \pi(n) \leq \frac{(m-1)\varphi(n)}{n}
     \]
     Since \(\pi(n) \geq \pi(m)\) (because \(n \geq m\)), \(\pi(m) - \pi(n) \leq 0\). The right-hand side is non-negative, so the inequality holds trivially.

2. **General Case \( n < m \):**
   - For each prime \( p \) such that \( n < p \leq m \), write \( p = nk + r \) where \( r \in \{1, 2, \ldots, n-1\} \) and \(\gcd(r, n) = 1\). There are \(\varphi(n)\) possible values for \( r \).
   - For each fixed \( r \), \( k \) must satisfy \( 1 \leq k \leq \frac{m-1}{n} \). Thus, there are \(\left\lfloor \frac{m-1}{n} \right\rfloor\) possible values for \( k \).

3. **Counting the Primes:**
   - The number of primes \( p \) such that \( n < p \leq m \) is at most \(\varphi(n) \left\lfloor \frac{m-1}{n} \right\rfloor\).
   - Therefore:
     \[
     \pi(m) - \pi(n) \leq \varphi(n) \left\lfloor \frac{m-1}{n} \right\rfloor
     \]
   - Since \(\left\lfloor \frac{m-1}{n} \right\rfloor \leq \frac{m-1}{n}\), we have:
     \[
     \pi(m) - \pi(n) \leq \varphi(n) \frac{m-1}{n}
     \]

4. **Equality Condition:**
   - Equality holds if and only if \(\left\lfloor \frac{m-1}{n} \right\rfloor = \frac{m-1}{n}\), which implies \( n \mid (m-1) \). Let \( m = nt + 1 \) for some positive integer \( t \).
   - For \( n \geq 3 \), there exists \( 1 < r_0 < n \) such 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.
   - Therefore, the only possible case is \( n = 2 \). We want \(\pi(m) = \frac{m+1}{2}\). This implies \( m \) must be odd, and \( 2 \) and all odd numbers not greater than \( m \) must be prime. This gives \( m = 3, 5, 7 \).

The final answer is \( \boxed{ (m, n) = (1, 1), (2, 1), (3, 1), (3, 2), (5, 2), (7, 2) } \).