# Prove that von Mangoldt function satisfies $\sum_{n \le x} \Lambda(n) \lfloor{\frac{x}{n}}\rfloor= x \ln(x)-x+O(\ln x)$

The picture above is what I have, which has an error that is too big.

Indeed, changing the $$\lfloor \frac xn \rfloor$$ to $$\frac xn + O(1)$$ will immediately incur an error that is $$O\big(\sum_{n\le x} \Lambda(n)\big) = O(x)$$.
One can write $$\lfloor \frac xn \rfloor$$ as the number of integers up to $$\frac xn$$, which leads to the following manipulation: $$\sum_{n\le x} \Lambda(n) \frac xn = \sum_{n\le x} \Lambda(n) \sum_{m\le x/n} 1 = \sum_{m\le x} \sum_{n\le x/m} \Lambda(n) = \sum_{m\le x} \psi\bigg(\frac xm\bigg).$$ Unfortunately, each summand has a reasonably large error term, so this doesn't seem like the way to go either. Indeed, to get an error term as small as $$O(\log x)$$, we don't want to use anything about primes at all—they simply aren't that well distributed.
However, $$\Lambda$$ is related to the smooth function $$\log$$ by $$\log m = \sum_{n\mid m} \Lambda(n)$$; so we should aim to create such a sum. And indeed we can do so, by writing $$\lfloor \frac xn \rfloor$$ not as the number of integers up to $$\frac xn$$ but rather as the number of multiples of $$n$$ up to $$x$$: $$\sum_{n\le x} \Lambda(n) \frac xn = \sum_{n\le x} \Lambda(n) \sum_{\substack{m\le x \\ n\mid m}} 1 = \sum_{m\le x} \sum_{\substack{n\le x \\ n\mid m}}\Lambda(n) = \sum_{m\le x} \sum_{n\mid m}\Lambda(n) = \sum_{m\le x} \log m.$$ Now the result follows by comparing this sum with the integral $$\int_0^x \log t\,dt$$.