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$?

  • 7
    $\begingroup$ Define "almost". $\endgroup$
    – lhf
    Jul 9, 2019 at 17:59
  • $\begingroup$ Estimating the tail of the sum by an integral could work. $\endgroup$ Jul 9, 2019 at 17:59
  • 2
    $\begingroup$ @lhf, thanks for asking me to define, I should define it without your question. I mean the best value of $m$ so that $|[S]-S|$ attains its minimum, where [ ] denotes the round function. $\endgroup$ Jul 9, 2019 at 18:03
  • 1
    $\begingroup$ Do you know the asymptotic of $f(m) = \sum_{n=1}^m \sqrt{n}$ ? Do you know how to improve the error term (the first steps of the Euler-Maclaurin summation formula) ? $\endgroup$
    – reuns
    Jul 9, 2019 at 18:06
  • 4
    $\begingroup$ Related: How close can $\sum_{k=1}^n \sqrt{k}$ be to an integer?. $\endgroup$
    – Martin R
    Jul 9, 2019 at 18:08

1 Answer 1


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.

  • 4
    $\begingroup$ I thought that this problem was beyond the reach of mortals. $\endgroup$
    – Piquito
    Jul 9, 2019 at 20:43
  • $\begingroup$ Can we use $(m+a)^{1/2} = m^{1/2}+ \frac{a}2 m^{-1/2}+O(a^2 m^{-3/2})$ to find the $m$ without computing the function ? $\endgroup$
    – reuns
    Jul 9, 2019 at 22:47
  • 7
    $\begingroup$ You really should submit this to OEIS. $\endgroup$
    – Deepak
    Jul 9, 2019 at 23:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .