Why are there repeated patterns in Ulam spiral for multiples? I had recently, just about a year ago, “discovered” that there are easy to see, clear patterns if you look at the Ulam spiral and just highlight the multiples for numbers.
By Ulam spiral I just mean the layout of spiralling out natural numbers.
These patterns are repeated in x and y direction.
Here are some examples, for multiples of n=22 and n=31


Note that these patterns appear for any scalar and its multipliers. There are no exceptions.
Needless to say, “prime numbers” live in points where some of these patterns appear for the first time, and never again. I have considered that this may be the reason why prime numbers seem to favour “diagonals”, because the multiplier patterns repeat clearly in x/y direction and not chaotically at all - but have not clearly been able to formulate this.
Since the Ulam spiral is based on tracing back the squares of all odd numbers (every bottom-right point - in some orientations this may be the bottom left, - is the next square of an odd number), this means that there are some “formula” F in $(2x+1)^2$ that all resolve to multipliers of a scalar, and these formula are dependent on some constants and $x$ only.
So far, I can only explain this for the pattern that appears at $n = 4$, where I can indeed see a formula in $(2n+1)^2-1$ which resolves to $4n^2+4n$ which obviously generates multipliers of 4.
I have not dared to “do the math” on the other patterns, which are more complex.
Now, a year has gone by and I have been thinking about this a lot, and it is driving me mad.
Could someone help me clear this up so I can let this matter rest?
I wrote a little more about it here - I might have gone into too much assumption in my initial enthusiasm on describing this “discovery” which may ultimately be only a trivial fact in arithmetics.
My question, what could be an explanation for the appearance of these repeated patterns?
https://github.com/buddhabrot/UlamAnalysis/blob/main/README.md
 A: The diagonal, horizontal and vertical lines of the Ulam spiral all have equations of the form $f(n) = 4n^2+bn+c$, as explained on Wikipedia or in this answer. Now say we have
$$
f(n) \equiv r \pmod m
$$
for some $r$ and $m$, then it follows that
$$
\begin{aligned}
f(n+m) &= 4(n+m)^2+b(n+m)+c\\
&= 4n^2+8nm+m^2+bn+bm+c\\
&= \underbrace{4n^2+bn+c}_{f(n)} + \underbrace{m(m+8n+b)}_{\text{multiple of $m$}}
\end{aligned}
$$
which means that
$$f(n+m) \equiv r \pmod m$$
as well. In other words, this is periodic of period $m$, in all directions (horizontally, vertically and diagonally). Finally, the rotation of the pattern in the East, West, North and South quadrants is simply an artefact due to the construction of the spiral itself.

[Edit] A few additional (scattered and maybe not so rigorous) thoughts.
Considering some $m \times m$ block in the Eastern quadrant, for instance
$$\begin{matrix}
\color{red}{30} &\color{red}{55} &88 &129 &178\\
29 &54 &87 &128 &177\\
28 &54 &86 &127 &176\\
27 &52 &\color{red}{85} &126 &\color{red}{175}\\
26 &51 &84 &\color{red}{125} &174
\end{matrix}
$$
it is easy to see that each column must contain exactly one element $\pmod m$ (here $5$). Therefore, leaving aside the regions in the neighborhood of the two main diagonals, every $m \times m$ block will have $m$ marked cells.
Now, in the example block above, I recognized the periodic sequence of quadratic residues $\bmod 5$, which is $\{0,1,4,4,1\}$, which led me to think that the patterns found by the OP are simply (and directly) the sequences of quadratic residues $\bmod m$. But alas, it isn't as simple as that, because we're taking quadratic polynomials modulo $m$. It remains predictable that the patterns will have some form of axial symmetry (due to the evenness of quadratics), and visual hints of parabolic curves shouldn't be too surprising either.
I don't know if much more can be said about the patterns, but I'll keep looking for a more precise characterization.
