Given an integer n in base 101010 and an integer k, return the sum of the digits of n after converting n into base k.
n
k
Constraints:
1≤n≤1001 \le n \le 1001≤n≤100
2≤k≤102 \le k \le 102≤k≤10
Now, let’s take a moment to make sure you’ve correctly understood the problem. The quiz below helps you check if you’re solving the correct problem:
Sum of Digits in Base K
For the input n=1, k=2, what is the sum of the digits after converting (n) to base (k)?
n=1, k=2
(2)
(1)
(0)
(3)
We have a game for you to play. Rearrange the logical building blocks to develop a clearer understanding of how to solve this problem.
Implement your solution in the following coding playground.