If current position is 1 , then any digit from [ 1 - 9 ] can be placed . If n = 1 , 0 can be also placed .
if ( digit == 1 ) : NEW_LINE INDENT start = 1 NEW_LINE if ( n == 1 ) : NEW_LINE INDENT start = 0 NEW_LINE DEDENT for i in range ( start , 10 ) : NEW_LINE INDENT val += countOfNumbers ( digit + 1 , i , prev1 , n ) NEW_LINE DEDENT DEDENT