a problem about averages of fractional parts I know a little analytic number theory , for example i know that:
$\sum_{d\le x}(\frac{x}{d}-[\frac {x}{d}])=\frac{x}{a}(1-\gamma)+O(\sqrt x)$
when the $\sum$ is over $d$'s the integers less or equal with $x$ that are congruent to $b$ mod $a$ and $\gamma $ is Euler's constant.
how can i prove this?
$$\sum_{p\le x}\left(\frac{x}{p}-\left[\frac {x}{p}\right]\right)=\frac{x}{\log x}(1-\gamma)+o\left(\frac{x}{\log x}\right)$$
it is really important to me,help me please!
thank you very much

$$\tag{1}\sum_{p\le n}\left(\frac{n}{p}-\left[\frac {n}{p}\right]\right)=\frac{n}{\log n}(1-\gamma)+o\left(\frac{n}{\log n}\right)\\\text{(the sum is over the primes $p\le n$)}$$
is a result from de la Vallée-Poussin (1898) "Sur les valeurs moyennes de certaines fonctions  arithmétiques" $(4.)$. Let's translate the part $4.$ for reference...
"The starting point is the well known equality (for $\,\log(n!)\,$ from Legendre with the exponent of $p$ in $n!$ given by $\,\displaystyle\sum_{j>0}\left[\frac n{p^j}\right]$) :
$$\tag{2}\sum_{p\le n} \log(p)\sum_{j>0}\left[\frac n{p^j}\right]=\sum_{k\le n}\log(k)$$
Let's note $\,\displaystyle r(p):=\frac np-\left[\frac np\right]\;$ and $\,\epsilon\to 0$ as $\dfrac 1n\to 0\;$ then (since $\dfrac n{p-1}=\dfrac np+\dfrac n{p^2}+\dfrac n{p^3}+\cdots$) $(2)$ divided by $n$ will give (concluding with Stirling's formula for $\log(n!)$) :
$$\tag{3}\sum_{p\le n} \frac{\log(p)}{p-1}-\frac 1n\sum_{p\le n}\log(p)\,r(p)=\frac 1n\sum_{k\le n}\log(k)+\epsilon_1=\log(n)-1+\epsilon_2$$
but it was shown (in de la Vallée-Poussin's proof of the PNT using the logarithmic derivative of the Euler product) that for $\gamma$ the Euler constant :
$$\tag{4}\sum_{p\le n} \frac{\log(p)}{p-1}=\log(n)-\gamma+\epsilon_3$$
Subtracting $(3)$ from $(4)$ we conclude that 
$$\tag{5}\frac 1n\sum_{p\le n} \log(p)\,r(p)=1-\gamma+\epsilon_4$$
Since the asymptotic number of primes $\le n$ is given by $\,\dfrac n{\log(n)}\,$ from the PNT the mean value of the fractions $r(p)$ will be (for $n$ infinitely large) : 
$$\tag{6} \frac {\log(n)}n \sum_{p\le n} r(p)$$ To prove that $(6)$ will converge to $\,1-\gamma\;$ like the left part of $(5)$ let's compute their difference 
$$\tag{7} \frac {\log(n)}n \sum_{p\le n} r(p)-\frac 1n\sum_{p\le n} \log(p)\,r(p)=\frac 1n\sum_{p\le n} (\log(n)-\log(p))\;r(p)$$
Since $0\le r(p)<1\,$ this will be positive and less than $\,\displaystyle \frac 1n\sum_{p\le n}(\log(n)-\log(p))\,$ which goes to $0$ as will be shown. The number of terms such that $\,p\le n\,$ has the asymptotic expression $\,\displaystyle (1+\epsilon)\frac n{\log(n)}$, further $\,\displaystyle \sum_{p\le n} \log(p)=(1+\epsilon')n\,$
 (as shown in the PNT paper) so that :
$$\tag{8} \frac 1n\sum_{p\le n}(\log(n)-\log(p))=\frac 1n\left[(1+\epsilon)\frac n{\log(n)}\log(n)+(1+\epsilon')n\right]=\epsilon-\epsilon'$$
which goes to $0$ with $\epsilon$ and $\epsilon'$.
This proves that $\,\displaystyle \frac {\log(n)}n \sum_{p\le n} r(p)=(1-\gamma)+o(1)\,$ and the theorem."
Ref: Friedrich Pillichshammer "Euler's constant and averages of fractional parts".
