If we have an $a\times b$ rectangle divided into unit squares with $L$ being a diagonal of the rectangle, how many of the unit squares that it contains also contain a point of $L$?
I initially started working with smaller cases and tried to form a generalisation. I struggled to find the link and after searching online came across the following: Total no. of squares containing diagonal = $a + b - \gcd(a,b)$.
But I would really like to improve my understanding of why it is so. May I please have some help with clarifying why we incorporate the gcd?
Thank you!