Smallest number possible by repeatedly multiplying with K or 2 exactly N times starting from 1 | Function to find the minimum value of X after increment X by K or twice value of X in each of N operations ; Iterate over the range [ 1 , N ] ; If the value of X is less than equal to K ; Otherwise ; Return the minimum value of X ; Driver Code
def minPossibleValue ( N , K , X ) : NEW_LINE INDENT for i in range ( 1 , N + 1 ) : NEW_LINE INDENT if ( X <= K ) : NEW_LINE INDENT X = X * 2 ; NEW_LINE DEDENT else : NEW_LINE INDENT X = X + K ; NEW_LINE DEDENT DEDENT return X ; NEW_LINE DEDENT N = 7 ; NEW_LINE K = 4 ; NEW_LINE X = 1 ; NEW_LINE print ( minPossibleValue ( N , K , X ) ) ; NEW_LINE