```
int fac(int a, int b){
int result = 1;
while(a > b){
result *= a;
a--;
}
return result;
}
int countNumbersWithUniqueDigits(int n) {
if(n == 1 || n == 0) return pow(10, n);
if(n > 10) return countNumbersWithUniqueDigits(10);
int result = 0;
result = countNumbersWithUniqueDigits(n - 1) + fac(9, 9-n) + fac(9, 9 - n + 1) * (n - 1);
return result;
}
```