Minimum time required to complete a work by N persons together | Java implementation of above approach ; Function to calculate the time ; Driver Code
import java . io . * ; class GFG { static double calTime ( double arr [ ] , int n ) { double work = 0 ; for ( int i = 0 ; i < n ; i ++ ) work += 1 / arr [ i ] ; return 1 / work ; } public static void main ( String [ ] args ) { double arr [ ] = { 6.0 , 3.0 , 4.0 } ; int n = arr . length ; System . out . println ( calTime ( arr , n ) + " ▁ Hours " ) ; } }