# Calculate a finite sum

I want to find out the best way to perform a concret summation. I know for instance that:

$$\sum_{i=1}^{p}\left \lfloor \sqrt{i} \right \rfloor=\int_{1}^{p+1}\left \lfloor \sqrt{i} \right \rfloor di$$ and then $$\int_{1}^{p+1}\left \lfloor \sqrt{i} \right \rfloor di=1/6\left (\left \lfloor \sqrt{p+1} \right \rfloor \right )\left ( 6p+5-2\left \lfloor \sqrt{p+1} \right \rfloor^{2}-3\left \lfloor \sqrt{p+1} \right \rfloor \right )$$ I would like to know the best way to compute $$\sum_{i=1}^{p}\left \lfloor \sqrt{ip} \right \rfloor$$ Is there an exact formula, like in the first case? If not, what would be the fastest method?

• The answer is an integer. Why are you talking about decimal positions? Commented Jul 2, 2020 at 18:49
• Right! Sorry, I was messing with another equation at the same time. I will edit the question. Thanks!
– Josi
Commented Jul 2, 2020 at 18:53
• No need to complicate this, think about it. How many times are you going to add $1$? ($3$ times), what about $2$? ($5$ times), what about $r$? ($2r+1$) times. Now try doing this by assuming certain restrictions on $p$, for example, $m^2 \leq p <(m+1)^2$ for some $m$. Commented Jul 2, 2020 at 19:06