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 i = 0 if n == 1 else 1 NEW_LINE while ( i <= 9 ) : NEW_LINE INDENT val += countOfNumbers ( digit + 1 , i , n ) NEW_LINE i += 1 NEW_LINE DEDENT DEDENT