Function to return the required position
static void noOfSquares ( int x1 , int y1 , int x2 , int y2 ) { int dx = Math . abs ( x2 - x1 ) ; int dy = Math . abs ( y2 - y1 ) ; int ans = dx + dy - __gcd ( dx , dy ) ; System . out . println ( ans ) ; }