I know very well that the sum of integers from $1$ to $n$ is $\dfrac{n\times(n+1)}2$. What I'm interested in today, and cannot find a solution for, is performing the opposite operation.
Let $m = \dfrac{n^2 + n} 2$. Knowing the value of $m$, how do I figure out the value of $n$? I could easily program a solution but I'd much prefer an algebraic one.
uint64_t n = sqrt(2.0 * m);
for small enough values ofm
. $\endgroup$