Determine the number of squares of unit area that a given line will pass through . | Function to return the required position ;  ; Driver Code
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 ) ; } function __gcd ( a , b ) { if ( b == 0 ) return a ; return __gcd ( b , a % b ) ; } var x1 = 1 , y1 = 1 , x2 = 4 , y2 = 3 ; noOfSquares ( x1 , y1 , x2 , y2 ) ;