There is a rectangle with dimensions and it is divided into equivalent number of unit squares that is of dimension . Now a diagonal is drawn in that rectangle calculate the number of squares that will be crossed by the diagonal?
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Let the height of the rectangular grid to have 199 rows and 991 columns. Let the left-bottom corner of the grid be the origin O ( 0 , 0 ) , then the right-top corner is P ( 9 9 1 , 1 9 9 ) . It is obvious that the diagonal passes through 199 rows and 991 columns and there is one count of crossing a square when the diagonal crosses a horizontal or vertical grid line. Since both 199 and 991 are primes, the diagonal passes only two corners of the 1 × 1 square at O ( 0 , 0 ) and P ( 9 9 1 , 1 9 9 ) . Therefore, the diagonal crosses 199 horizontal and 991 vertical grid lines with the last two together at P ( 9 9 1 , 1 9 9 ) , the number of squares crossed is 1 9 9 + 9 9 1 − 1 = 1 1 8 9 .