Find pair with greatest product in array | Function to find greatest number ; Driver code
function findGreatest ( arr , n ) { let result = - 1 ; for ( let i = 0 ; i < n ; i ++ ) for ( let j = 0 ; j < n - 1 ; j ++ ) for ( let k = j + 1 ; k < n ; k ++ ) if ( arr [ j ] * arr [ k ] == arr [ i ] ) result = Math . max ( result , arr [ i ] ) ; return result ; } let arr = [ 30 , 10 , 9 , 3 , 35 ] ; let n = arr . length ; document . write ( findGreatest ( arr , n ) ) ;