Corner to corner

 

Use this program to determine the relationship between the number of rows and columns of a rectangle (or square) and the number of squares its diagonal passes through.

 

You can verify that the relationship is of the form:

Squares passed = rows + columns - highest common factor of rows and columns.