Solution to $\frac{n(n+1)}{2} \leq x<\frac{(n+1)(n+2)}{2}$ when given $x$ I tried to find a solution to
$$\frac{n(n+1)}{2} \leq x<\frac{(n+1)(n+2)}{2} \tag0$$
when $x$ is given $(n \in \mathbb N_0, x \geq 0)$.
This inequality means $n$-th triangular number is the greastest triangular number less than or equal to $x$.
There is one and only one $n \in \mathbb N_0$ given $x \geq 0$.
$$\text{if}\; x \in [0, 1),\; n = 0$$
$$\text{if}\; x \in [1, 3),\; n = 1$$
$$\text{if}\; x \in [3, 6),\; n = 2$$
$$...$$
Split the inequality in two, we get
$$\frac{n(n+1)}{2} \leq x   \tag1$$
$$x<\frac{(n+1)(n+2)}{2}   \tag2$$
Focus on $(1)$. Using quadratic formula for $(1)$,
$$\frac{-1 - \sqrt{8x+1}}{2} \leq n \leq \frac{-1 + \sqrt{8x+1}}{2}   \tag{$1.1$}$$
Note that $n \in \mathbb N_0$, maximum value of $n$ is
$$n = \lfloor \frac{-1 + \sqrt{8x+1}}{2} \rfloor   \tag{1.2}$$
and this is the solution to the original inequality $(0)$. Only maximum value is allowed, because if $n=$ (value less than the maximum) is the solution, then $n=$ (the maximum value) is another solution, which breaks the uniqueness of $n$.
Similarly using quadratic formula for $(2)$,
$$n < \frac{-3 - \sqrt{8x+1}}{2}\; \lor\; n > \frac{-3 + \sqrt{8x+1}}{2}   \tag{$2.1$}$$
And the solution (the minimum value) is
$$ n = 
     \begin{cases}
       \lceil \frac{-3 + \sqrt{8x+1}}{2} \rceil &\quad\text{if}\; \frac{-3 + \sqrt{8x+1}}{2} \not \in \mathbb N_0\\
       \frac{-3 + \sqrt{8x+1}}{2} + 1 &\quad\text{if}\; \frac{-3 + \sqrt{8x+1}}{2} \in \mathbb N_0\\
    \end{cases}\tag{$2.2$}$$
Actually $(1.2)$ and $(2.2)$ are the same thing with different notation.
Interestingly, I found
$$n = \lfloor \sqrt{\frac{\lfloor \sqrt{2x} \rfloor}{\lfloor \sqrt{2x} \rfloor +1}} \cdot \sqrt{2x} \rfloor   \tag3$$
I cannot find any relationship between $(3)$ and $(1.2)$ or $(3)$ and $(0)$, but it seems like $(3)$ is also a solution.
(I brute-forced for $x \in \mathbb{N}_0$, $x \leq 50000000$)
So this is my question: Is $(3)$ the solution to $(0)$?
P.S.
Modify $(0)$ slightly,
$$n(n+1) \leq 2x < (n+1)(n+2) \tag{0.1}$$
and substitude $X = 2x$
$$n(n+1) \leq X < (n+1)(n+2) \tag{0.2}$$
$$n = \lfloor \sqrt{\frac{\lfloor \sqrt{X} \rfloor}{\lfloor \sqrt{X} \rfloor +1}} \cdot \sqrt{X} \rfloor   \tag{3.1}$$
Now the problem is more simple: Is $(3.1)$ the solution to $(0.2)$?

Well, by solving:

*

*$$x=\frac{\text{n}\left(\text{n}+1\right)}{2}\space\Longleftrightarrow\space\text{n}=\frac{\pm\sqrt{1+8x}-1}{2}\tag1$$

*$$x=\frac{\left(\text{n}+1\right)\left(\text{n}+2\right)}{2}\space\Longleftrightarrow\space\text{n}=\frac{\pm\sqrt{1+8x}-3}{2}\tag2$$
We can see that we have the following solutions:

*

*$$\text{n}=-\frac{1}{2}\space\wedge\space x=-\frac{1}{8}\tag3$$

*For $-\frac{1}{8}<x<0$:
$$-\frac{\sqrt{1+8x}+1}{2}\le\text{n}\le\frac{\sqrt{1+8x}-1}{2}\tag4$$

*For $x\ge0$:
$$\frac{\sqrt{1+8x}-3}{2}<\text{n}\le\frac{\sqrt{1+8x}-1}{2}\tag5$$
And for solving $\text{k}^2=1+8x$, such that $\sqrt{1+8x}\in\mathbb{N}$, you can see that:

*

*$$x=\text{c}_1\left(1+2\text{c}_1\right)\space\wedge\space\text{k}=1+4\text{c}_1\tag6$$
Where $\text{c}_1\in\mathbb{Z}$

*$$x=2\text{c}_2^2+3\text{c}_2+1\space\wedge\space\text{k}=3+4\text{c}_2\tag7$$
Where $\text{c}_2\in\mathbb{Z}$
So, we can see two cases for $x\ge0$:

*

*$$\frac{1+4\text{c}_1-3}{2}=2\text{c}_1-1<\text{n}\le2\text{c}_1=\frac{1+4\text{c}_1-1}{2}\tag8$$

*$$\frac{3+4\text{c}_2-3}{2}=2\text{c}_2<\text{n}\le1+2\text{c}_2=\frac{3+4\text{c}_2-1}{2}\tag9$$
