Find Harmonic mean using Arithmetic mean and Geometric mean | Function to calculate arithmetic mean , geometric mean and harmonic mean ; Driver Code
function compute ( a , b ) { var AM = ( a + b ) / 2 ; var GM = Math . sqrt ( a * b ) ; var HM = ( GM * GM ) / AM ; return HM ; } var a = 5 ; var b = 15 ; var HM = compute ( a , b ) document . write ( " " + a + " " + b + " " + HM . toFixed ( 3 ) ) ;