$\underline{\text{Motivation}:-}$
This is a sort of sub-question of my previous question
In that question I asked about finding the formula for the ulam spiral. Answering the question I will ask here, will help get closer to the answer for the original question (Atleast in my approach).
$\underline{\text{Why am I asking this separately}?}$
I think this question is not a duplicate of the question I linked because in the original question, i asked about the ulam spiral along with the questions about my approach to solve it (Is my approach correct? And what would be a better approach?). While here I am asking this specific question in it's own right and I do think that this question is interesting in it's own right.
If that is the case then why did I linked the original one? Well because people reading this question might be curious that why I ask such a random question out of nowhere, so I thought giving the motivation might be a good idea.
$\underline{\text{Details}:-}$
Let,
$\begin{align}&L_1=\{L^2-L,\cdots,L^2-1\}\\&L_2=\{L^2,\cdots,L^2+L-1\}\end{align}$
For $L\in\mathbb{N}$
For example,
$1_1=\{0\}$
$1_2=\{1\}$
$2_1=\{2,3\}$
$2_2=\{4,5\}$
$3_1=\{6,7,8\}$
$3_2=\{9,10,11\}$
$4_1=\{12,13,14,15\}$
$\vdots$
It's clear that $\bigcup_{L\in\mathbb{N}}(L_1\cup L_2)=\mathbb{N}$
I want to find a method which finds $L$ for a given natural number $n$.
To do that, it seems that I need to solve for $L$ in the equation
$L^2+k=n$
where, $n\in\mathbb{N}$ and $L\leq n$ and $k$ is an integer with $-L\leq k\leq L-1$
And if we solve for $k$ too then we can also say whether $n\in L_1$ or $n\in L_2$
Since, $L=n$ only when $n=1$
So we have to solve for $L$ and $k$ in
$\begin{cases}L^2+k=n\\-L\leq k\leq L-1\\1<L<n\end{cases}$
$\underline{\text{My Question}:-}$
To clear off what I am really asking-
How to solve for $L$ and $k$ in
$\begin{cases}L^2+k=n\\-L\leq k\leq L-1\\1<L<n\end{cases}$
(I feel really bad for not being able to find a solution to an equation only involving perfect squares, but to be honest I really don't know how to approach this question. I have been trying to solve this question for the last few days without any particular success. So I would request the mathematician folks out there to help me)