Count of pairs satisfying the given condition | Function to return the number of pairs satisfying the equation ; Converting integer b to string by using to_function ; Loop to check if all the digits of b are 9 or not ; If '9' doesn 't appear  then break the loop ; If all the digits of b contain 9 then multiply a with length else multiply a with length - 1 ; Return the number of pairs ; Driver code
def countPair ( a , b ) : NEW_LINE INDENT s = str ( b ) NEW_LINE i = 0 NEW_LINE while i < ( len ( s ) ) : NEW_LINE INDENT if ( s [ i ] != '9' ) : NEW_LINE INDENT break NEW_LINE DEDENT i += 1 NEW_LINE DEDENT result = 0 NEW_LINE if ( i == len ( s ) ) : NEW_LINE INDENT result = a * len ( s ) NEW_LINE DEDENT else : NEW_LINE INDENT result = a * ( len ( s ) - 1 ) NEW_LINE DEDENT return result NEW_LINE DEDENT a = 5 NEW_LINE b = 101 NEW_LINE print ( countPair ( a , b ) ) NEW_LINE