Count of all possible numbers not exceeding M having suffix N | Function to count the no . of digits of N ; Function to count all possible numbers having Suffix as N ; Difference of the A . P ; Count of the number of terms ; Driver code
def digitsOf ( num ) : NEW_LINE INDENT return len ( str ( num ) ) ; NEW_LINE DEDENT def count ( a , tn ) : NEW_LINE INDENT diff = int ( pow ( 10 , digitsOf ( a ) ) ) ; NEW_LINE return ( ( tn - a ) / diff ) + 1 ; NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 25 ; m = 4500 ; NEW_LINE print ( int ( count ( n , m ) ) ) ; NEW_LINE DEDENT