Sum of k-Mirror Numbers
A k-mirror number is a positive integer without leading zeros that reads the same both forward and backward in base-10 as well as in base-k.
Given the base k and the number n, return the sum of the n smallest k-mirror numbers.
Example 1
Input
k = 2, n = 5Output
25The 5 smallest 2-mirror numbers are 1, 3, 5, 7, and 9, whose sum is 25.
Example 2
Input
k = 3, n = 7Output
499The 7 smallest 3-mirror numbers are 1, 2, 4, 8, 121, 151, and 212, whose sum is 499.
Constraints
- 2 <= k <= 9
- 1 <= n <= 30