Given a number on the Ulam Spiral, I want to know how many 90° turns were taken to arrive at that number. For example, to get to the number 10, you need to turn at 2, 3, 5, and 7 for a total of four turns.
I know how to generate the sequence of numbers where the turns occur, they follow the form:
$$y = \lfloor (n+2)^2/4 \rfloor+1$$
Here $y$ is a turning point number on the spiral and $n$ is the number of turns. For the example above, if we input $n=4$ (for 4 turns) we get:
$$y = \lfloor (4+2)^2/4 \rfloor+1 = \lfloor 36/4 \rfloor+1 = 10$$
However, I not sure how to solve for the number of turns ($n$) given some $y$ because the $floor()$ function has no inverse. Any insight would be appreciated.
EDIT
After looking at John Omielan's answer I realized if you solve the even equation for $k$, ignore the negative solution, and round up the answer it seems to work:
$$n = \left\lceil 2\sqrt{y-1}-2\right\rceil$$
I can't proof this works for every number, but it seems promising.