I have two natural numbers, $x$ and $y$. I repeatedly subtract the smaller one from the bigger one until $x$ and $y$ are both 1.
I need to find how many times I have do that for a given $x$ and $y$, if it is possible. If it's not possible to get to x=1 and y=1, I want to know that.
Example:
x=7, y=4
x=3, y=4
x=3, y=1
x=2, y=1
x=1,y=1
Done. Took 4 steps.
Example 2:
x=4, y=2
x=2, y=2
-> Impossible
I could just repeat the steps over and over, but I need to find the answer for potentially really big numbers, and I suspect a rather easy pattern. The steps seem to be related to the difference between x and y, but the pattern only worked for values up until 9.
None of the patterns I found worked for all the numbers, so some help would be appreciated.