Function to return the required position
function noOfSquares ( x1 , y1 , x2 , y2 ) { var dx = Math . abs ( x2 - x1 ) ; var dy = Math . abs ( y2 - y1 ) ; var ans = dx + dy - __gcd ( dx , dy ) ; document . write ( ans ) ; }