$S=\sqrt{1}+\sqrt{2}+\sqrt{3}+\sqrt{4}+\dots+\sqrt{m}$ is almost an integer. Find $m$ For an integers $m$ and $n$, $1<m\le n$ , we need to find the best $m$ so that $S=\sqrt{1}+\sqrt{2}+\sqrt{3}+\sqrt{4}+\dots+\sqrt{m}$ is almost an integer.


*

*Example: when $n=40$, then the best value of $m$ is $38$, where $S$ become $159.046\dots$
I used Microsoft Excel and observes the sums, term-by-term, of the series, which is not a sufficient way for large values of $n$.
Using mathematical equations and formulae, not programs like Excel,

How to find the best value of $m$ if we are given larger values of $n$?

 A: Let
$$
F(m) \equiv \left| \sum_{n=1}^{m}\sqrt{n} - \left[ \sum_{n=1}^{m}\sqrt{n} \right] \right|
$$
where $[x]$ denotes the nearest integer to $x$. A small value of $F(m)$ tells you that the sum of the first $m$ square roots is near to an integer.
What you are really looking for is the sequence of $m_i$ where $m_i$ is monotonic increasing with $i$ and for each $m_i$
$$
k < m_i \Longrightarrow F(k) > F(m_i)
$$
That is, the sequence of "closest to an integer yet" values of $m$.
The easy way to see the start of this sequence is to note that the asymptotic form of 
$\sum_1^m\sqrt{n}$  is 
$$
\sum_1^m\sqrt{n}\approx \frac1{\sqrt{n}}\left(\frac{2n^2}{3}+\frac{n}2 +\zeta(-\frac12) \sqrt{n}+\frac1{24}-\frac1{1920 n^2}+ \frac1{9216 n^4}-\frac{11}{163840 n^6}+\frac{65}{786432 n^8}\right)
$$
Then in Mathematica you gan define $F[m]$ as that expression, $G[m]$ as Abs$[F[m]-$Round$[F[m]]$ and do a series of DiscretePlot of $G[m]$ to see where you get new minima.
When you do this for up to $m=10^6$ you find the sequence for $m_i$ is 
$$
\{ 3, 13, 22, 33, 38, 41, 54, 156, 761, 10869, 41085, 142625, 224015, 898612\ldots\}
$$
So for example, when $n=500$ the best value of $m$ will be $156$, at which point 
$$
\sum_1^{156}\sqrt{n}\approx 1305.0000314264
$$
The sequence $m_i$ given above is not in OEIS.

The next number in the sequence is $2750788$ and 
$$
\sum_1^{2750788}\sqrt{n}\approx 3041547064.000000030776
$$
That nearness ($3\cdot 10^{-8}$) is a significant improvement over its predecessor, which is off by a bit more than one part in a million.
