Sums involving floor function I am looking for a direct formula for this sum
$$\sum_{k=0}^n \lfloor{\sqrt{n+k}}\rfloor\lfloor{\sqrt{k}}\rfloor$$
Or a method to efficiently compute the sum for large n
 A: I do not think that a closed form could exist.
Generating value for $100\leq n\leq 10000$ by step of $100$ and plotting the results shows something very close to a power law. Using nonlinear regression, what I obtained is $$S_n=\sum_{k=0}^n \lfloor{\sqrt{n+k}}\rfloor\lfloor{\sqrt{k}}\rfloor\approx 0.781411\, n^{2.0067}$$ where both parameters are highly significant as show below $$\begin{array}{clclclclc}
 \text{} & \text{Estimate} & \text{Standard Error} & \text{Confidence Interval} \\
 a & 0.781411 & 0.000529556 & \{0.78036,0.782462\} \\
 b & 2.006700 & 0.000075149 & \{2.00655,2.006850\} \\
\end{array} $$
 I suppose that we could keep the exponent equal to $2$ and get $$S_n \approx 0.830070\, n^2$$
You should notice that, as Yves Daoust commented, $$\int_0^1\sqrt{1+x}\sqrt x \,dx=\frac{1}{4} \left(3 \sqrt{2}-\sinh ^{-1}(1)\right)\approx 0.840317$$
A: Here's an exact $O(\sqrt{n})$ formula:
$$\left\lfloor \sqrt{n}\right\rfloor  \left((n+1) \left\lfloor \sqrt{n}\right\rfloor +\frac{1}{3} \left(-\left(\left\lfloor \sqrt{n}\right\rfloor +1\right)^3+\frac{3}{2} \left(\left\lfloor \sqrt{n}\right\rfloor +1\right)^2+\frac{1}{2} \left(-\left\lfloor \sqrt{n}\right\rfloor -1\right)\right)\right)+\frac{1}{6} \left\lfloor \sqrt{n}\right\rfloor  \left(-\left\lfloor \sqrt{n}\right\rfloor  \left(2 \left\lfloor \sqrt{n}\right\rfloor +3\right)+6 n+5\right) \left\lfloor \sqrt{2} \sqrt{n}-\left\lfloor \sqrt{n}\right\rfloor \right\rfloor +\sum _{j=\left\lfloor \sqrt{n}\right\rfloor +1}^{\left\lfloor \sqrt{2n} \right\rfloor } \left(\left\lfloor \sqrt{j^2-n}\right\rfloor ^3-\left(j^2-n\right) \left\lfloor \sqrt{j^2-n}\right\rfloor -\frac{1}{6} \left(\left\lfloor \sqrt{j^2-n}\right\rfloor -1\right) \left(4 \left\lfloor \sqrt{j^2-n}\right\rfloor +1\right) \left\lfloor \sqrt{j^2-n}\right\rfloor \right)$$
It can be derived via the following steps:


*the $\left\lfloor\sqrt{k+n}\right\rfloor$ factor can be ignored at first; substitute in $\sqrt{n}$ and use the known formula for summing $\left\lfloor\sqrt{k}\right\rfloor$

*now add in the deficit:  each $k$ where $\left\lfloor\sqrt{k+n}\right\rfloor$ increases by $1$ (there are $O(\sqrt{n})$ such points), sum $\left\lfloor\sqrt{k}\right\rfloor$ from this $k$ to $n$ (use the known formula again, with suitable modifications).

*Clean up: shift the summation index to make the sum formula maybe nicer looking; pull factors which only depend on $n$ outside the sum, etc.

