One would think that $\big((2n-1)^2-2k^2\big)$ could be any odd number but it is always $\big|(2n-1)^2-2k^2\big| \in\big\{1, 7,17,23,31,41,\cdots\big\} , (n,k)\in\mathbb{N}, GCD\big((2n-1),k\big)=1$
These numbers are "congruent" to $\pm 1\pmod 8$ but that's just a word to me that means they have a remainder of $1$ or $7$ after division by $8$. Answers and comments so far have referenced things about modularity that I haven't been able to make sense of with online study of wiki, etc.
There are other numbers like $9, 15, 25, 33, \cdots$ that also have this property but only prime power "products" are produced. (Examples: $\space P^0=1,\space 7^2=49,\space 7\cdot 17=119)\space $ Now, given modularity, I can understand that these prime-power-products have a remainder of $\pm 1 \pmod 8$ but it doesn't explain why-primes and why $\pmod 8$.
Can someone help me understand the why-primes part? I'm still wondering why-$\pmod 8$ vs $\pmod 4$ or some other but I may be able to figure out the rest from there.
Let $$a^2+b^2=c^2\tag{1}$$
If $\gcd(a,b,c)=1$ then the solution may be written $$\begin{align}a&=2mn\\b&=m^2-n^2\\c&=m^2+n^2\end{align}$$
We therefore have $b-a=(m+n)^2-2n^2$. Suppose there is a prime $p$ such that $p\mid b-a$. We know that $p\mid m\iff p\mid n$, so we may assume that $p$ divides neither. We can then write $$(m+n)^2\equiv_p 2n^2$$ This means that $2$ is a square in the ring $\Bbb Z_p$. This happens only when $p\equiv_8\pm 1$. Thus all the primes are on this form, which implies that $$b-a\equiv_8 \pm 1$$
Proof: Notice that $$\begin{align}p-1&\equiv_p 1\cdot (-1)^1\\2&\equiv_p 2\cdot (-1)^2\\p-3&\equiv_p 3\cdot (-1)^3\\&\vdots\\p\pm\frac{p-1}{2}&\equiv_p\frac{p-1}{2}(-1)^{\frac{p-1}{2}}\end{align}$$ Multiplying all the above we get $$2^{\frac{p-1}{2}}\left(\frac{p-1}{2}\right)!\equiv_p \left(\frac{p-1}{2}\right)!(-1)^{\frac{p^2-1}{8}}$$ Since $p\not\mid \left(\frac{p-1}{2}\right)!$ we get $$\left(\frac{2}{p}\right)\equiv_p (-1)^\frac{p^2-1}{8}$$