Prove that for any positive integer $\displaystyle n$, there exist unique positive integers $\displaystyle k$ and $\displaystyle r$ such that $\displaystyle n = \frac{k(k-1)}{2}+r$ with $\displaystyle 1\le r\le k$.
Prove that for any positive integer $\displaystyle n$, there exist unique positive integers $\displaystyle k$ and $\displaystyle r$ such that $\displaystyle n = \frac{k(k-1)}{2}+r$ with $\displaystyle 1\le r\le k$.
Consider the set $\displaystyle \{ n - \tfrac{x(x-1)}{2}\geq 0 | x\in \mathbb{Z}^+ \}$. There exists a smallest integer $\displaystyle n - \tfrac{k(k-1)}{2} = r$. We claim that $\displaystyle r\leq k$. Assume not, then $\displaystyle r>k$ and we can write $\displaystyle r=r_0+k$ where $\displaystyle r_0<r$. Thus, we have $\displaystyle n - \tfrac{k(k-1)}{2} = r_0+k$ which gives $\displaystyle n-\tfrac{(k+1)k}{2} = r_0$. And this is a contradiction since $\displaystyle r$ was supposed to be minimal.