Find the smallest value of N such that sum of first N natural numbers is â ‰¥ X | Function to check if sum of first N natural numbers is >= X ; Finds minimum value of N such that sum of first N natural number >= X ; Check if sum of first i natural number >= X ; Driver Code ; Input ; Finds minimum value of N such that sum of first N natural number >= X
def isGreaterEqual ( N , X ) : NEW_LINE INDENT return ( N * ( N + 1 ) // 2 ) >= X NEW_LINE DEDENT def minimumPossible ( X ) : NEW_LINE INDENT for i in range ( 1 , X + 1 ) : NEW_LINE INDENT if ( isGreaterEqual ( i , X ) ) : NEW_LINE INDENT return i NEW_LINE DEDENT DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT X = 14 NEW_LINE print ( minimumPossible ( X ) ) NEW_LINE DEDENT