Pair with given product | Set 1 ( Find if any pair exists ) | Returns true if there is a pair in arr [ 0. . n - 1 ] with product equal to x . ; Consider all possible pairs and check for every pair . ; Driver code
function isProduct ( arr , n , x ) { for ( var i = 0 ; i < n - 1 ; i ++ ) for ( var j = i + 1 ; i < n ; i ++ ) if ( arr [ i ] * arr [ j ] == x ) return true ; return false ; } var arr = [ 10 , 20 , 9 , 40 ] ; var x = 400 ; var n = arr . length ; isProduct ( arr , n , x ) ? document . write ( " " ) : document . write ( " " ) ; x = 190 ; isProduct ( arr , n , x ) ? document . write ( " " ) : document . write ( " " ) ;