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
def minSum ( N ) : NEW_LINE INDENT low = 0 NEW_LINE high = 1000000000 NEW_LINE while ( low + 1 < high ) : NEW_LINE INDENT mid = low + ( high - low ) / 2 NEW_LINE if ( mid * mid >= N ) : NEW_LINE INDENT high = mid NEW_LINE DEDENT else : NEW_LINE INDENT low = mid NEW_LINE DEDENT DEDENT first = high NEW_LINE low = 0 NEW_LINE high = 1000000000 NEW_LINE while ( low + 1 < high ) : NEW_LINE INDENT mid = low + ( high - low ) / 2 NEW_LINE if ( first * mid > N ) : NEW_LINE INDENT high = mid NEW_LINE DEDENT else : NEW_LINE INDENT low = mid NEW_LINE DEDENT DEDENT second = high NEW_LINE print ( round ( first + second ) ) NEW_LINE DEDENT N = 10 NEW_LINE minSum ( N ) NEW_LINE