```
public class Solution {
public int countNumbersWithUniqueDigits(int n) {
if(n == 0) return 0;
if(n == 1) return 10;
if(n > 10) return countNumbersWithUniqueDigits(10);
int k = n, sum = 9;
while(k > 1){
sum *= (11 - k);
k--;
}
return sum + countNumbersWithUniqueDigits(n-1);
}
}
```