Minimum sum of two integers whose product is strictly greater than N | Function to find the minimum sum of two integers such that their product is strictly greater than N ; Initialise low as 0 and high as 1e9 ; Iterate to find the first number ; Find the middle value ; If mid ^ 2 is greater than equal to A , then update high to mid ; Otherwise update low ; Store the first number ; Again , set low as 0 and high as 1e9 ; Iterate to find the second number ; Find the middle value ; If first number * mid is greater than N then update high to mid ; Else , update low to mid ; Store the second number ; Print the result ; Driver Code ; Function Call
function minSum ( N ) { let low = 0 , high = 1000000000 ; while ( low + 1 < high ) { let mid = low + parseInt ( ( high - low ) / 2 ) ; if ( mid * mid >= N ) { high = mid ; } else { low = mid ; } } let first = high ; low = 0 ; high = 1000000000 ; while ( low + 1 < high ) { let mid = low + parseInt ( ( high - low ) / 2 ) ; if ( first * mid > N ) { high = mid ; } else { low = mid ; } } let second = high ; document . write ( first + second ) ; } let N = 10 ; minSum ( N ) ;