text: Minimum time required to fill a cistern using N pipes | Function to calculate the time ; Driver Code
code: function Time ( arr , n , Emptypipe ) { var fill = 0 ; for ( var i = 0 ; i < n ; i ++ ) fill += 1 / arr [ i ] ; fill = fill - ( 1 / Emptypipe ) ; return 1 / fill ; } var arr = [ 12 , 14 ] ; var Emptypipe = 30 ; var n = arr . length ; document . write ( Math . floor ( Time ( arr , n , Emptypipe ) ) + " " ) ;