The below exercise appears in a book in section of GCD, and linear Diophantine equation (LDE).
A square of side $1$ is divided in $a$ strips by equally spaced $(a-1)$ red lines parallel to a side, and is divided in $b$ strips by equally spaced $(b-1)$ blue lines parallel to red strips. What is the minimum distance between the red and blue lines.
For application of GCD, need form linear Diophantine equations(LDEs) to use the properties, assume WLOG (hoping that this would not affect the solution in other cases), that $a \nmid b, b\nmid a$.
So, $(a,b)=1$ and this should help to form the LDE $ax + by =1$.
To get the minimum distance, may be the book's answer helps: it is given as $(a,b)/ab.$
I want to at least see the logic of this answer, if there is division of a side of unit length into $5$ and $6$ parts by $4$ red and $5$ blue lines respectively, then how come the minimum distance is $1/30$.
If I draw on a graph paper, then the lines are as shown below :
$$ \begin{align} 0.2 <--> & \ 0.166 \\ 0.4 <--> & \ 0.332 \\ 0.6 <--> & \ 0.498 \\ 0.8 <--> & \ 0.664 \\ none <--> & \ 0.830 \\ \end{align} $$
The minimum distance is between $0.830, 0.8 => 0.030 = 1/30.$
So, the author wants to take the linear combination (in my example) of $-a'.4 + b'.5$ to arrive at the minimum value of $1/30$, where $a'$ is for red strip length ($=0.2 = 1/a $), and $b'$ is for blue. Note that $a$ = #red strips = #red lines +1, $b$ =#blue strips= #blue lines +1, even though the distance is between lines only.
So, effectively the question reduces to finding the Bezout's coefficients for the smallest possible linear combination, which for my example is :$a=0.2, b = 0.166$. So, is $(a,b) = 1/(5.6)$ an example of $\gcd$ for rational numbers.
You are really asking about $\min \left(\frac k{a-1}, \frac m{b-1}\right)$ where $k,m$ are naturals and $k \lt a-1, m \lt b-1$. It will be $\frac 1{\operatorname{lcm}(a-1,b-1)}=\frac {\gcd(a-1,b-1)}{(a-1)(b-1)}$ and your approach is the right way to find them.