I need help with this question
I have problem like this: I have rectangle with fixed size NxM, such that N, M are positive natural numbers. And this rectangle of size NxM is splited on squares with size 1x1, actually if the rectangle sizes are 3x3, it is splited on 9 squares. This picture is showing.

And actually the picture is also showing the thing i want to find, the number of small squares in which the diagonal of the rectangle is passing. In all 4 variants it is passing in 4 squares.
Thanks in advance.