Digit Sum in Base K
Write n in base k, then add up its digits, treating each digit as an ordinary base 10 number. Return that sum as a base 10 integer.
Example 1
n 34
k 6
returns 9
34 is 54 in base 6, and 5 + 4 = 9.
Example 2
n 10
k 10
returns 1
1 + 0 = 1.
Constraints
1 <= n <= 1000002 <= k <= 16
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More Math problems
- Digital RootBeginner
- Excel Sheet Column NumberBeginner
- Handshake CountBeginner
- Harshad NumberBeginner
- Hex String to DecimalBeginner
- Highest Power of TwoBeginner
- Is PrimeBeginner
- Lattice Points in a CircleBeginner