Count of rectangles possible from N and M straight lines parallel to X and Y axis respectively | Function to calculate number of rectangles ; Total number of ways to select two lines parallel to X axis ; Total number of ways to select two lines parallel to Y axis ; Total number of rectangles ; Driver Code
function count_rectangles ( N , M ) { let p_x = ( N * ( N - 1 ) ) / 2 ; let p_y = ( M * ( M - 1 ) ) / 2 ; return p_x * p_y ; } let N = 3 ; let M = 6 ; document . write ( count_rectangles ( N , M ) ) ;