Given $n$, what is the largest $m$ such that $m^2\prod_{i=1}^n(p_i-2)+\prod_{i=1}^n(p_i-1)\le \prod_{i=0}^np_i$? (Using $p_n$ as the $n+1$th prime, i.e., $p_0=2$.)  After starting with attempting to find the largest $m$ such that
$$\sum_{i=1}^m(2i-1)\prod_{j=1}^{n}(p_j-2)\le p_n\#-\varphi(p_n\#)$$
I rearranged this inequality to

$m^2\prod_{i=1}^n(p_i-2)+\prod_{i=1}^n(p_i-1)\le \prod_{i=0}^np_i$

Edit: an incorrect estimate gives way to a correct one... one immediate point is to note that $p-2\lt p-1$ while $p_{i+1}-2\ge p_i-1$ giving that $p_n\prod(p-2)\ge \prod(p-1)$, and as a follow-up we generally have $n\approx\log (p_n\#)$ with $\varphi(p_n\#)\approx \frac{p_n\#}{\log(p_n\#)}$ giving that $m\approx n$ is a reasonable starting point.  The first couple $m$ (with $p_0=2$) are
$$n=1, m=2\\
n=2, m=2\\
n=3, m=3
$$
Are there any other approaches for this question or known estimate improvements that would give a better estimate than $n$ for $m$?
 A: Divide the inequality by $\prod_{i = 1}^n p_i$ to obtain
$$m^2 \prod_{i = 1}^{n} \biggl(1 - \frac{2}{p_i}\biggr) \leqslant 2 - \prod_{i = 1}^{n} \biggl(1 - \frac{1}{p_1}\biggr)\,.$$
By Mertens's third theorem the right hand side is
$$2 - \frac{2}{e^{\gamma}\log p_n} + O\biggl(\frac{1}{(\log p_n)^2}\biggr)\,.$$
On the left hand side, write
$$1 - \frac{2}{p} = \biggl(1 - \frac{1}{p}\biggr)^2 - \frac{1}{p^2} = \biggl(1 - \frac{1}{p}\biggr)^2\cdot \biggl(1 - \frac{1}{(p-1)^2}\biggr)$$
to obtain
$$C_2m^2\frac{4}{e^{2\gamma}(\log p_n)^2}\cdot \biggl(1 + O\biggl(\frac{1}{\log p_n}\biggr)\biggr)$$
where
$$C_2 = \prod_{p \geqslant 3}\biggl(1 - \frac{1}{(p-1)^2}\biggr) \approx 0.6601618$$
is the twin prime constant. The error from stopping this product at $p_n$ is of much smaller order than the error in Mertens's theorem (even if we use the best possible bounds [assuming the Riemann hypothesis] there), namely
$$1 - \prod_{i = n}^{\infty} \biggl(1 - \frac{1}{(p_i-1)^2}\biggr) \sim \frac{1}{p_n\log p_n}\,,$$
thus it is absorbed by the latter.
Hence we obtain the inequality
$$m^2 \leqslant \frac{e^{2\gamma}(\log p_n)^2}{2C_2} + O(\log p_n)$$
which yields
$$m \leqslant \frac{e^{\gamma}\log p_n}{\sqrt{2C_2}} + O(1)\,.$$
If we use better bounds obtainable from the prime number theorem with error term instead of the bounds proved by Mertens, we get
$$m^2 \leqslant \frac{e^{2\gamma}(\log p_n)^2}{2C_2} - \frac{e^{\gamma}\log p_n}{2C_2} + o(1)$$
and
$$m \leqslant \frac{e^{\gamma}\log p_n}{\sqrt{2C_2}} - \frac{1}{2} + o(1)\,.$$
Of course these asymptotics are only good for sufficiently large $n$, but "sufficiently" isn't very large. It's decent for $n \geqslant 2$, and "pretty good" already for $n \geqslant 10$.
