```
public class Solution {
public int CountNumbersWithUniqueDigits(int n) {
if (n == 0) return 1;
// We begin with 9, instead of 10
// to skip all numbers that are not n digits
int fact = 9;
for (int i = 1; i < n; i++)
{
fact *= (10 - i);
}
return fact + CountNumbersWithUniqueDigits(n-1);
}
}
```