TITLE: Relatively primes spirals
QUESTION [16 upvotes]: When exploring the structure of points of the integer lattice
whose two coordinates are relatively prime
(call these r-prime points),1
I looked at spirals analogous to "Gaussian prime spirals."2
Start at an r-prime point $(a,b)$,
walk vertically (North) until you hit another r-prime point,
then walk West until another r-prime point is hit, then South, then East,
continuing to turn counterclockwise
$90^\circ$ at r-prime points until you re-encounter an earlier point,
approached from the same direction as last hit, and so fall
into a cycle.
(The start point is
considered approached from its left.)
Unlike the Gaussian prime spirals, these "relatively primes spirals"
are not generally visually interesting.
Many are just $4$-cycles, e.g.:
$$
(223, 2), (223, 3), (221, 3), (221, 2)
$$
Let me illustrate one more before asking a question.
Starting at $(495,2)$ leads to a cycle of length $44$:
$$
(495, 2), (495, 4), (493, 4), (493, 3), (494, 3), (494, 5), (493, 5),
(493, 4), (495, 4), (495, 7), (494, 7), (494, 5), (496, 5), (496, 7),
(495, 7), (495, 4), (497, 4), (497, 5), (496, 5), (496, 3), (497, 3),
(497, 4), (495, 4), (495, 2), (497, 2), (497, 3), (496, 3), (496, 1),
(497, 1), (497, 2), (495, 2), (495, 1), (496, 1), (496, 3), (494, 3),
(494, 1), (495, 1), (495, 2), (493, 2), (493, 1), (494, 1), (494, 3),
(493, 3), (493, 2)
$$
Here is an illustration of this cycle:

         


A natural question is:

Does any start point lead to an infinite path that never cycles?

A candidate infinite path starts at $(5,2)$:
$$
(5, 2), (5, 3), (4, 3), (4, 1), (5, 1), (5, 2), (3, 2), (3, 1), (4, 1), (4, 3),
(2,3), (2,1), \ldots
$$
Here is its first $200$ turns:

         


And here is its first $1000$ turns:

         


And here is its first $10000$ turns:

         


I've tracked it out to $10^6$ turns (reaching out to $(87652,87655)$), and still no cycle.
So, in addition to the general question above, a more specific question
is whether $(5,2)$ ever cycles.
Added animation:

         



1Arbitrarily long composite anti-diagonals?
2Gaussian prime spirals

REPLY [11 votes]: First note that, in the path, the coordinates are always positive, because whenever any coordinate decreases to $1$ you hit a relatively prime point, turn, hit another relatively prime point, and then the coordinate starts increasing again,
Next consider the following set of posiitions and next directions:
A $(x,y), y>x+1$, any direction 
B $(x,x+1)$, North, East, or West
C $(x,x-1)$, North
This set is closed under your operation. The reason is that if you ever leave type A you must be traveling South or East and hit the R-prime point $(x,x+1)$, so you are then traveling East or North, hence be in type B. If you leave type B and travel North or West you return to A, and traveling east you skip the non-R-prime point $(x+1,x+1)$ (note $x$ is at least $1$) and travel straight to $(x+2,x+1)$ and turn North, hence in a point in C. Finally C returns to B in the same way by skipping $(x,x)$ (note $x$ is at least $2$) and turning West.
Because your spiral enters this closed set, it never leaves it and hence never returns to its initial point. Because the flow is reversible, this means it must run forever without repeating.