/*
* @lc app=leetcode.cn id=357 lang=typescript
*
* [357] 计算各个位数不同的数字个数
*/
// @lc code=start
function countNumbersWithUniqueDigits(n: number): number {}
// @lc code=end
function countNumbersWithUniqueDigits(n: number): number {
let sum = 0
for (let i = 1; i <= n; i++) {
let tmp = 1,
base = 9
for (let j = 0; j < i; j++) {
tmp *= base
if (j > 0) base--
}
sum += tmp
}
return sum + 1
}
test.each([
{ input: { n: 2 }, output: 91 },
{ input: { n: 0 }, output: 1 },
])('input: n = $input.n', ({ input: { n }, output }) => {
expect(countNumbersWithUniqueDigits(n)).toEqual(output)
})