Having the number 59 for example find $x$ which $x^2$ is closer but lower to the 59. In this case is 7 I don't know how to name this but this is what I would need.
42  43  44  45  46  47  48  49
41  20  21  22  23  24  25  50
40  19  6   7   8   9   26  51
39  18  5   0   1   10  27  52
38  17  4   3   2   11  28  
37  16  15  14  13  12  29  
36  35  34  33  32  31  30  

This is a map of blocks. It starts by 0 and the go 1, 2, 3, 4, 5.... circular clockwise. So given that I know the number 52, in this case I would like to know it's $(x, y)$, which in this case is $(x=4,\ y=0)$.
The first thing I need is:


*

*Having the number 59 for example find $x$ which $x^2$ is closer but lower to the 59. In this case is 7.


Which gives me the magnitude, to know how away from 0 is, then based on that I have the length of the square, this means how many blocks are on each side. In the case of 52, I get the number 7 based on that: $52-49+1 = 4$. With the 4 then I will make a loop until it finds the position. It will turn after 8 times.
Any help is appreciated, thanks very much!

This type of construction is known as an Ulam spiral, so you might want to search for that. It has connections to prime numbers. For example, diagonals on the spiral correspond to quadratic polynomials. The youtube channel Numberphile has a great video on this subject.
