If an ant crawls from one corner to the other corner of a 3 \times 5 rectangle, then it will cross through seven squares.
If the ant crawls from one corner to the other corner of a 4 \times 4 rectangle, then how many squares will it cross through?
The number of squares crossed by an ant crawling diagonally across an
l*w rectangle formula is
l+w−gcd(l,w)
.
The rectangle dimensions are
4*4 so l=4, w=4
4+4-gcd(4,4)=8-4=4