Solution (source code)

= Solution

Let $p_1,\ldots,p_a$ be the first $a$ <primes>, and let $\phi(x,a)$ count positive integers at most $x$ not divisible by any of them. The <inclusion-exclusion principle> gives
$$
\phi(x,a)=\sum_{S\subseteq\{1,\ldots,a\}}(-1)^{|S|}\left\lfloor\frac{x}{\prod_{j\in S}p_j}\right\rfloor.
$$
For $a=\pi(\sqrt x)$, every composite at most $x$ is removed, so the survivors are one and the <primes> larger than $\sqrt x$. Thus the <Legendre prime-counting formula> is $\boxed{\pi(x)=\phi(x,\pi(\sqrt x))+\pi(\sqrt x)-1}$. This is the prime-counting formula, distinct from the factorial-valuation formula of the same name.

Fix $y\geq2$ and put $a=\pi(y)$. Every <prime> exceeding $y$ is among the unsieved integers. Replacing each floor in the finite sum by its argument makes an error bounded by $2^a$, giving
$$
\pi(x)\leq a+\phi(x,a)\leq a+x\prod_{p\leq y}(1-1/p)+2^a.
$$
Take $x\to\infty$ with $y$ fixed. The supplied product estimate gives $0\leq\limsup\pi(x)/x\leq1/\log y$. Since $y$ can be arbitrarily large, $\boxed{\lim_{x\to\infty}\pi(x)/x=0}$. The order of these limits avoids treating the growing inclusion-exclusion error as negligible.