<s>[INST] Upper bound on summation involving fractional part Let $x\in[1,+\infty)\subset\mathbb{R}$. I would like to show that
$$\sum_{d=1}^{\lfloor x\rfloor}\left(\frac{x}{d}-\left\lfloor\frac{x}{d}\right\rfloor\right)\leq x-1,$$
where $\lfloor\cdot\rfloor$ is the floor function. I understand that, since $$\frac{x}{d}-\left\lfloor\frac{x}{d}\right\rfloor\leq1,$$
we have
$$\sum_{d=1}^{\lfloor x\rfloor}\left(\frac{x}{d}-\left\lfloor\frac{x}{d}\right\rfloor\right)\leq \sum_{d=1}^{\lfloor x\rfloor}1=\lfloor x\rfloor\leq x.$$
How can I come up with the finer bound? Any hints? Thank you in advance.
 [/INST] We have
\begin{align*}
& \sum\limits_{d = 1}^{\left\lfloor x \right\rfloor } {\left( {\frac{x}{d} - \left\lfloor {\frac{x}{d}} \right\rfloor } \right)}  = \sum\limits_{d = 1}^{\left\lfloor x \right\rfloor } {\left( {\frac{x}{d} - \left\lfloor {\frac{{\left\lfloor x \right\rfloor }}{d}} \right\rfloor } \right)}  = \sum\limits_{d = 1}^{\left\lfloor x \right\rfloor } {\left( {\frac{x}{d} - \frac{{\left\lfloor x \right\rfloor }}{d}} \right)}  + \sum\limits_{d = 1}^{\left\lfloor x \right\rfloor } {\left( {\frac{{\left\lfloor x \right\rfloor }}{d} - \left\lfloor {\frac{{\left\lfloor x \right\rfloor }}{d}} \right\rfloor } \right)} 
\\ & \le (x - \left\lfloor x \right\rfloor )\sum\limits_{d = 1}^{\left\lfloor x \right\rfloor } {\frac{1}{d}}  + \sum\limits_{d = 1}^{\left\lfloor x \right\rfloor } {\left( {1 - \frac{1}{d}} \right)}  = (x - \left\lfloor x \right\rfloor  - 1)\sum\limits_{d = 1}^{\left\lfloor x \right\rfloor } {\frac{1}{d}}  + \sum\limits_{d = 1}^{\left\lfloor x \right\rfloor } 1 
\\ & = x - 1 + (x - \left\lfloor x \right\rfloor  - 1)\sum\limits_{d = 2}^{\left\lfloor x \right\rfloor } {\frac{1}{d}}  \le x - 1.
\end{align*}
</s>