Check if current and current + 1 can be valid placements
if ( current >= 0 and current <= 9 ) : NEW_LINE INDENT val += countOfNumbers ( digit + 1 , current , prev1 , n ) NEW_LINE DEDENT if ( ( current + 1 ) >= 0 and ( current + 1 ) <= 9 ) : NEW_LINE INDENT val += countOfNumbers ( digit + 1 , current + 1 , prev1 , n ) NEW_LINE DEDENT