Number of points in the diagonal of an $X \times Y$ square lattice box.

So assuming we have a $X \times Y$ lattice, Say for example a $3 \times 5$ like so

* * *
* * *
* * *
* * *
* * *


I need to find the number of points that each diagonal passes through. In this example, each diagonal passes through 3 points. Any help is much appreciated!

• Wouldn't it just be $\min(X,Y)$? – naslundx Mar 19 '14 at 17:10
• Take a 4*3 one, it doesn't work in that case. – Veritas Mar 19 '14 at 17:11
• What is a diagonal in this case then? I assumed you meant a straight line from the corner that's not horizontal or vertical? – naslundx Mar 19 '14 at 17:13
• I am talking about the top-left/bottom-right and top-right/bottom-left diagonals. Sorry for the ambiguous wording. – Veritas Mar 19 '14 at 17:17
• Hmm...maybe it's: $$1 + \gcd(X - 1, Y - 1)$$ – Adriano Mar 19 '14 at 17:19